2015-11-16 11:21:57 -08:00
|
|
|
|
// 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;
|
2016-04-19 22:51:32 -05:00
|
|
|
|
using Microsoft.DotNet.Cli.Utils;
|
2016-11-15 11:56:39 -08:00
|
|
|
|
using Microsoft.DotNet.Tools.MSBuild;
|
2015-10-06 10:46:43 -07:00
|
|
|
|
|
2015-10-07 14:39:36 -07:00
|
|
|
|
namespace Microsoft.DotNet.Tools.Publish
|
2015-10-06 10:46:43 -07:00
|
|
|
|
{
|
2017-02-23 11:24:36 -08:00
|
|
|
|
public partial class PublishCommand : MSBuildForwardingApp
|
2015-10-06 10:46:43 -07:00
|
|
|
|
{
|
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)
|
2015-10-06 10:46:43 -07:00
|
|
|
|
{
|
2015-10-13 14:31:29 -07:00
|
|
|
|
DebugHelper.HandleDebugSwitch(ref args);
|
|
|
|
|
|
2017-03-08 17:53:07 -08:00
|
|
|
|
var msbuildArgs = new List<string>();
|
2016-04-22 15:01:56 -07:00
|
|
|
|
|
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();
|
|
|
|
|
}
|
2016-10-27 18:46:43 -07:00
|
|
|
|
}
|
2017-03-08 17:53:07 -08:00
|
|
|
|
}
|