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.
|
|
|
|
|
|
2016-04-19 22:51:32 -05:00
|
|
|
|
using Microsoft.DotNet.Cli.CommandLine;
|
|
|
|
|
using Microsoft.DotNet.Cli.Utils;
|
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
|
|
|
|
{
|
2016-01-30 21:47:50 -08:00
|
|
|
|
public partial class PublishCommand
|
2015-10-06 10:46:43 -07:00
|
|
|
|
{
|
2016-01-30 21:47:50 -08:00
|
|
|
|
public static int Run(string[] args)
|
2015-10-06 10:46:43 -07:00
|
|
|
|
{
|
2015-10-13 14:31:29 -07:00
|
|
|
|
DebugHelper.HandleDebugSwitch(ref args);
|
|
|
|
|
|
2016-10-27 18:46:43 -07:00
|
|
|
|
CommandLineApplication app = new CommandLineApplication(throwOnUnexpectedArg: false);
|
2015-10-06 10:46:43 -07:00
|
|
|
|
app.Name = "dotnet publish";
|
|
|
|
|
app.FullName = ".NET Publisher";
|
|
|
|
|
app.Description = "Publisher for the .NET Platform";
|
2016-10-27 18:46:43 -07:00
|
|
|
|
app.AllowArgumentSeparator = true;
|
|
|
|
|
app.ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText;
|
2015-10-06 10:46:43 -07:00
|
|
|
|
app.HelpOption("-h|--help");
|
|
|
|
|
|
2016-10-27 18:46:43 -07:00
|
|
|
|
CommandArgument projectArgument = app.Argument("<PROJECT>",
|
|
|
|
|
"The MSBuild project file to publish. If a project file is not specified, MSBuild searches the current" +
|
|
|
|
|
" working directory for a file that has a file extension that ends in `proj` and uses that file.");
|
2015-10-06 10:46:43 -07:00
|
|
|
|
|
2016-10-27 18:46:43 -07:00
|
|
|
|
CommandOption frameworkOption = app.Option(
|
|
|
|
|
"-f|--framework <FRAMEWORK>", "Target framework to publish for",
|
|
|
|
|
CommandOptionType.SingleValue);
|
|
|
|
|
|
|
|
|
|
CommandOption runtimeOption = app.Option(
|
|
|
|
|
"-r|--runtime <RUNTIME_IDENTIFIER>", "Target runtime to publish for. The default is to publish a portable application.",
|
|
|
|
|
CommandOptionType.SingleValue);
|
|
|
|
|
|
|
|
|
|
CommandOption outputOption = app.Option(
|
|
|
|
|
"-o|--output <OUTPUT_DIR>", "Path in which to publish the app",
|
|
|
|
|
CommandOptionType.SingleValue);
|
2015-12-02 23:32:27 -08:00
|
|
|
|
|
2016-10-27 18:46:43 -07:00
|
|
|
|
CommandOption configurationOption = app.Option(
|
|
|
|
|
"-c|--configuration <CONFIGURATION>", "Configuration under which to build",
|
|
|
|
|
CommandOptionType.SingleValue);
|
2016-02-03 10:57:25 -08:00
|
|
|
|
|
2016-10-27 18:46:43 -07:00
|
|
|
|
CommandOption versionSuffixOption = app.Option(
|
|
|
|
|
"--version-suffix <VERSION_SUFFIX>", "Defines the value for the $(VersionSuffix) property in the project",
|
|
|
|
|
CommandOptionType.SingleValue);
|
2016-04-22 15:01:56 -07:00
|
|
|
|
|
2016-10-27 18:46:43 -07:00
|
|
|
|
app.OnExecute(() =>
|
|
|
|
|
{
|
|
|
|
|
var publish = new PublishCommand();
|
2015-10-06 10:46:43 -07:00
|
|
|
|
|
2016-10-27 18:46:43 -07:00
|
|
|
|
publish.ProjectPath = projectArgument.Value;
|
|
|
|
|
publish.Framework = frameworkOption.Value();
|
|
|
|
|
publish.Runtime = runtimeOption.Value();
|
|
|
|
|
publish.OutputPath = outputOption.Value();
|
|
|
|
|
publish.Configuration = configurationOption.Value();
|
|
|
|
|
publish.VersionSuffix = versionSuffixOption.Value();
|
|
|
|
|
publish.ExtraMSBuildArguments = app.RemainingArguments;
|
2015-11-29 00:14:30 -08:00
|
|
|
|
|
2016-10-27 18:46:43 -07:00
|
|
|
|
return publish.Execute();
|
2015-10-06 10:46:43 -07:00
|
|
|
|
});
|
|
|
|
|
|
2016-10-27 18:46:43 -07:00
|
|
|
|
return app.Execute(args);
|
2015-10-06 10:46:43 -07:00
|
|
|
|
}
|
2016-10-27 18:46:43 -07:00
|
|
|
|
}
|
2015-10-06 10:46:43 -07:00
|
|
|
|
}
|