dotnet-installer/src/dotnet/commands/dotnet-publish/Program.cs

56 lines
1.6 KiB
C#
Raw Normal View History

// 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.
2017-03-08 17:53:07 -08:00
using System.Collections.Generic;
2017-02-22 12:45:11 -08:00
using Microsoft.DotNet.Cli;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Tools.MSBuild;
2015-10-07 14:39:36 -07:00
namespace Microsoft.DotNet.Tools.Publish
{
2017-02-23 11:24:36 -08:00
public partial class PublishCommand : MSBuildForwardingApp
{
2017-02-23 11:24:36 -08:00
private PublishCommand(IEnumerable<string> msbuildArgs, string msbuildPath = null)
: base(msbuildArgs, msbuildPath)
{
}
2017-02-22 12:45:11 -08:00
public static PublishCommand FromArgs(string[] args, string msbuildPath = null)
{
DebugHelper.HandleDebugSwitch(ref args);
2017-03-08 17:53:07 -08:00
var msbuildArgs = new List<string>();
2017-03-08 17:53:07 -08:00
var parser = Parser.Instance;
2017-02-23 11:24:36 -08:00
2017-03-08 17:53:07 -08:00
var result = parser.ParseFrom("dotnet publish", args);
2017-02-23 11:24:36 -08:00
2017-03-08 17:53:07 -08:00
msbuildArgs.Add("/t:Publish");
2017-02-23 11:24:36 -08:00
2017-03-08 17:53:07 -08:00
var appliedPublishOption = result.AppliedOptions["publish"];
2017-02-23 11:24:36 -08:00
2017-03-08 17:53:07 -08:00
msbuildArgs.AddRange(appliedPublishOption.Arguments);
2017-02-23 11:24:36 -08:00
2017-03-08 17:53:07 -08:00
msbuildArgs.AddRange(appliedPublishOption.ArgsToBeForwarded());
2017-02-22 12:45:11 -08:00
2017-02-23 11:24:36 -08:00
return new PublishCommand(msbuildArgs, msbuildPath);
2017-02-22 12:45:11 -08:00
}
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();
}
}
2017-03-08 17:53:07 -08:00
}