// Copyright (c) .NET Foundation and contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; using Microsoft.DotNet.Cli; using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.Tools.MSBuild; namespace Microsoft.DotNet.Tools.Publish { public partial class PublishCommand : MSBuildForwardingApp { private PublishCommand(IEnumerable msbuildArgs, string msbuildPath = null) : base(msbuildArgs, msbuildPath) { } public static PublishCommand FromArgs(string[] args, string msbuildPath = null) { DebugHelper.HandleDebugSwitch(ref args); var msbuildArgs = new List(); var parser = Parser.Instance; var result = parser.ParseFrom("dotnet publish", args); msbuildArgs.Add("/t:Publish"); var appliedPublishOption = result.AppliedOptions["publish"]; msbuildArgs.AddRange(appliedPublishOption.Arguments); msbuildArgs.AddRange(appliedPublishOption.ArgsToBeForwarded()); return new PublishCommand(msbuildArgs, msbuildPath); } public static int Run(string[] args) { DebugHelper.HandleDebugSwitch(ref args); PublishCommand cmd; try { cmd = FromArgs(args); } catch (CommandCreationException e) { return e.ExitCode; } return cmd.Execute(); } } }