Skip to content

Update self contained/ runtime command line options for build and publish #18837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/Cli/dotnet/CommonLocalizableStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -689,4 +689,14 @@ setx PATH "%PATH%;{0}"
<data name="CannotSpecifyBothRuntimeAndOsOptions" xml:space="preserve">
<value>Specifying both the `-r|--runtime` and `-os` options is not supported.</value>
</data>
<data name="SelfContainedOptionDescription" xml:space="preserve">
<value>Publish the .NET runtime with your application so the runtime doesn't need to be installed on the target machine.
The default is 'true' if a runtime identifier is specified.</value>
</data>
<data name="FrameworkDependentOptionDescription" xml:space="preserve">
<value>Publish your application as a framework dependent application. A compatible .NET runtime must be installed on the target machine to run your application.</value>
</data>
<data name="SelfContainAndNoSelfContainedConflict" xml:space="preserve">
<value>The '--self-contained' and '--no-self-contained' options cannot be used together.</value>
</data>
</root>
22 changes: 21 additions & 1 deletion src/Cli/dotnet/CommonOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static Option RuntimeOption(string description, bool withShortOption = tr
description)
{
ArgumentHelpName = CommonLocalizableStrings.RuntimeIdentifierArgumentName
}.ForwardAsSingle(o => $"-property:RuntimeIdentifier={o}")
}.ForwardAsMany(o => new string[] { $"-property:RuntimeIdentifier={o}", "-property:_CommandLineDefinedRuntimeIdentifier=true" })
.AddSuggestions(Suggest.RunTimesFromProjectFile());

public static Option CurrentRuntimeOption(string description) =>
Expand Down Expand Up @@ -109,6 +109,18 @@ public static Option OperatingSystemOption() =>

public static Option DebugOption() => new Option<bool>("--debug");

public static Option SelfContainedOption() =>
new ForwardedOption<bool>(
"--self-contained",
CommonLocalizableStrings.SelfContainedOptionDescription)
.ForwardAsMany(o => new string[] { $"-property:SelfContained={o}", "-property:_CommandLineDefinedSelfContained=true" });

public static Option NoSelfContainedOption() =>
new ForwardedOption<bool>(
"--no-self-contained",
CommonLocalizableStrings.FrameworkDependentOptionDescription)
.ForwardAsMany(o => new string[] { "-property:SelfContained=false", "-property:_CommandLineDefinedSelfContained=true" });

public static bool VerbosityIsDetailedOrDiagnostic(this VerbosityOptions verbosity)
{
return verbosity.Equals(VerbosityOptions.diag) ||
Expand All @@ -117,6 +129,14 @@ public static bool VerbosityIsDetailedOrDiagnostic(this VerbosityOptions verbosi
verbosity.Equals(VerbosityOptions.detailed);
}

public static void ValidateSelfContainedOptions(bool hasSelfContainedOption, bool hasNoSelfContainedOption)
{
if (hasSelfContainedOption && hasNoSelfContainedOption)
{
throw new GracefulException(CommonLocalizableStrings.SelfContainAndNoSelfContainedConflict);
}
}

internal static IEnumerable<string> ResolveArchOptionToRuntimeIdentifier(string arg, ParseResult parseResult)
{
if (parseResult.HasOption(RuntimeOption(string.Empty).Aliases.First()))
Expand Down
4 changes: 3 additions & 1 deletion src/Cli/dotnet/commands/dotnet-build/BuildCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using Parser = Microsoft.DotNet.Cli.Parser;
using System.CommandLine.Parsing;
using System;
using System.Linq;

namespace Microsoft.DotNet.Tools.Build
{
Expand All @@ -33,6 +32,9 @@ public static BuildCommand FromArgs(string[] args, string msbuildPath = null)

parseResult.ShowHelpOrErrorIfAppropriate();

CommonOptions.ValidateSelfContainedOptions(parseResult.HasOption(BuildCommandParser.SelfContainedOption),
parseResult.HasOption(BuildCommandParser.NoSelfContainedOption));

msbuildArgs.Add($"-consoleloggerparameters:Summary");

if (parseResult.HasOption(BuildCommandParser.NoIncrementalOption))
Expand Down
12 changes: 10 additions & 2 deletions src/Cli/dotnet/commands/dotnet-build/BuildCommandParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ internal static class BuildCommandParser

public static readonly Option NoRestoreOption = CommonOptions.NoRestoreOption();

public static readonly Option SelfContainedOption = CommonOptions.SelfContainedOption();

public static readonly Option NoSelfContainedOption = CommonOptions.NoSelfContainedOption();

public static readonly Option RuntimeOption = CommonOptions.RuntimeOption(LocalizableStrings.RuntimeOptionDescription);

public static Command GetCommand()
{
var command = new Command("build", LocalizableStrings.AppFullName);
Expand All @@ -39,7 +45,7 @@ public static Command GetCommand()
RestoreCommandParser.AddImplicitRestoreOptions(command, includeRuntimeOption: false, includeNoDependenciesOption: false);
command.AddOption(CommonOptions.FrameworkOption(LocalizableStrings.FrameworkOptionDescription));
command.AddOption(CommonOptions.ConfigurationOption(LocalizableStrings.ConfigurationOptionDescription));
command.AddOption(CommonOptions.RuntimeOption(LocalizableStrings.RuntimeOptionDescription));
command.AddOption(RuntimeOption);
command.AddOption(CommonOptions.VersionSuffixOption());
command.AddOption(NoRestoreOption);
command.AddOption(CommonOptions.InteractiveMsBuildForwardOption());
Expand All @@ -49,7 +55,9 @@ public static Command GetCommand()
command.AddOption(NoIncrementalOption);
command.AddOption(NoDependenciesOption);
command.AddOption(NoLogoOption);
command.AddOption(CommonOptions.ArchitectureOption());
command.AddOption(SelfContainedOption);
command.AddOption(NoSelfContainedOption);
command.AddOption(CommonOptions.ArchitectureOption());
command.AddOption(CommonOptions.OperatingSystemOption());

return command;
Expand Down
10 changes: 0 additions & 10 deletions src/Cli/dotnet/commands/dotnet-publish/LocalizableStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,6 @@
<data name="ManifestOptionDescription" xml:space="preserve">
<value>The path to a target manifest file that contains the list of packages to be excluded from the publish step.</value>
</data>
<data name="SelfContainedOptionDescription" xml:space="preserve">
<value>Publish the .NET runtime with your application so the runtime doesn't need to be installed on the target machine.
The default is 'true' if a runtime identifier is specified.</value>
</data>
<data name="NoBuildOptionDescription" xml:space="preserve">
<value>Do not build the project before publishing. Implies --no-restore.</value>
</data>
Expand All @@ -155,10 +151,4 @@ The default is to publish a framework-dependent application.</value>
<data name="CmdNoLogo" xml:space="preserve">
<value>Do not display the startup banner or the copyright message.</value>
</data>
<data name="NoSelfContainedOptionDescription" xml:space="preserve">
<value>Publish your application as a framework dependent application without the .NET runtime. A supported .NET runtime must be installed to run your application.</value>
</data>
<data name="SelfContainAndNoSelfContainedConflict" xml:space="preserve">
<value>The '--self-contained' and '--no-self-contained' options conflict with each other. Specify only one of the options.</value>
</data>
</root>
7 changes: 2 additions & 5 deletions src/Cli/dotnet/commands/dotnet-publish/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,8 @@ public static PublishCommand FromArgs(string[] args, string msbuildPath = null)

msbuildArgs.Add("-target:Publish");

if (parseResult.HasOption(PublishCommandParser.SelfContainedOption) &&
parseResult.HasOption(PublishCommandParser.NoSelfContainedOption))
{
throw new GracefulException(LocalizableStrings.SelfContainAndNoSelfContainedConflict);
}
CommonOptions.ValidateSelfContainedOptions(parseResult.HasOption(PublishCommandParser.SelfContainedOption),
parseResult.HasOption(PublishCommandParser.NoSelfContainedOption));

msbuildArgs.AddRange(parseResult.OptionValuesToBeForwarded(PublishCommandParser.GetCommand()));

Expand Down
14 changes: 7 additions & 7 deletions src/Cli/dotnet/commands/dotnet-publish/PublishCommandParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ internal static class PublishCommandParser
public static readonly Option NoBuildOption = new ForwardedOption<bool>("--no-build", LocalizableStrings.NoBuildOptionDescription)
.ForwardAs("-property:NoBuild=true");

public static readonly Option SelfContainedOption = new ForwardedOption<bool>("--self-contained", LocalizableStrings.SelfContainedOptionDescription)
.ForwardAsSingle(o => $"-property:SelfContained={o}");

public static readonly Option NoSelfContainedOption = new ForwardedOption<bool>("--no-self-contained", LocalizableStrings.NoSelfContainedOptionDescription)
.ForwardAs("-property:SelfContained=false");

public static readonly Option NoLogoOption = new ForwardedOption<bool>("--nologo", LocalizableStrings.CmdNoLogo)
.ForwardAs("-nologo");

public static readonly Option NoRestoreOption = CommonOptions.NoRestoreOption();

public static readonly Option SelfContainedOption = CommonOptions.SelfContainedOption();

public static readonly Option NoSelfContainedOption = CommonOptions.NoSelfContainedOption();

public static readonly Option RuntimeOption = CommonOptions.RuntimeOption(LocalizableStrings.RuntimeOptionDescription);

public static Command GetCommand()
{
var command = new Command("publish", LocalizableStrings.AppDescription);
Expand All @@ -55,7 +55,7 @@ public static Command GetCommand()
command.AddOption(NoSelfContainedOption);
command.AddOption(NoLogoOption);
command.AddOption(CommonOptions.FrameworkOption(LocalizableStrings.FrameworkOptionDescription));
command.AddOption(CommonOptions.RuntimeOption(LocalizableStrings.RuntimeOptionDescription));
command.AddOption(RuntimeOption);
command.AddOption(CommonOptions.ConfigurationOption(LocalizableStrings.ConfigurationOptionDescription));
command.AddOption(CommonOptions.VersionSuffixOption());
command.AddOption(CommonOptions.InteractiveMsBuildForwardOption());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@
<target state="translated">Cílová architektura pro publikování. Cílová architektura musí být zadaná v souboru projektu.</target>
<note />
</trans-unit>
<trans-unit id="NoSelfContainedOptionDescription">
<source>Publish your application as a framework dependent application without the .NET runtime. A supported .NET runtime must be installed to run your application.</source>
<target state="translated">Publikujte svoji aplikaci jako aplikaci závislou na architektuře bez modulu runtime .NET. Aby bylo možné vaši aplikaci spustit, musí být nainstalovaný podporovaný modul runtime .NET.</target>
<note />
</trans-unit>
<trans-unit id="OutputOption">
<source>OUTPUT_DIR</source>
<target state="translated">OUTPUT_DIR</target>
Expand Down Expand Up @@ -64,18 +59,6 @@ Ve výchozím nastavení je publikována aplikace závislá na architektuře.</t
<target state="translated">Konfigurace pro publikování. Výchozí možností pro většinu projektů je Debug.</target>
<note />
</trans-unit>
<trans-unit id="SelfContainAndNoSelfContainedConflict">
<source>The '--self-contained' and '--no-self-contained' options conflict with each other. Specify only one of the options.</source>
<target state="translated">Možnosti --self-contained a --no-self-contained jsou vzájemně konfliktní. Zadejte pouze jednu z nich.</target>
<note />
</trans-unit>
<trans-unit id="SelfContainedOptionDescription">
<source>Publish the .NET runtime with your application so the runtime doesn't need to be installed on the target machine.
The default is 'true' if a runtime identifier is specified.</source>
<target state="translated">Publikujte se svou aplikací modul runtime pro .NET, aby ho nebylo nutné instalovat na cílovém počítači.
Pokud se zadá identifikátor modulu runtime, výchozí hodnota je true.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@
<target state="translated">Das Zielframework für die Veröffentlichung. Das Zielframework muss in der Projektdatei angegeben werden.</target>
<note />
</trans-unit>
<trans-unit id="NoSelfContainedOptionDescription">
<source>Publish your application as a framework dependent application without the .NET runtime. A supported .NET runtime must be installed to run your application.</source>
<target state="translated">Hiermit wird Ihre Anwendung als Framework-abhängige Anwendung ohne .NET-Runtime veröffentlicht. Es muss eine unterstützte .NET-Runtime installiert sein, um Ihre Anwendung auszuführen.</target>
<note />
</trans-unit>
<trans-unit id="OutputOption">
<source>OUTPUT_DIR</source>
<target state="translated">OUTPUT_DIR</target>
Expand Down Expand Up @@ -64,18 +59,6 @@ Standardmäßig wird eine Framework-abhängige Anwendung veröffentlicht.</targe
<target state="translated">Die Konfiguration für die Veröffentlichung. Der Standardwert für die meisten Projekte ist "Debug".</target>
<note />
</trans-unit>
<trans-unit id="SelfContainAndNoSelfContainedConflict">
<source>The '--self-contained' and '--no-self-contained' options conflict with each other. Specify only one of the options.</source>
<target state="translated">Die Optionen "--self-contained" und "--no-self-contained" stehen in Konflikt zueinander. Geben Sie nur eine der Optionen an.</target>
<note />
</trans-unit>
<trans-unit id="SelfContainedOptionDescription">
<source>Publish the .NET runtime with your application so the runtime doesn't need to be installed on the target machine.
The default is 'true' if a runtime identifier is specified.</source>
<target state="translated">Hiermit wird die .NET-Runtime mit Ihrer Anwendung veröffentlicht, sodass die Runtime nicht auf dem Zielcomputer installiert werden muss.
Der Standardwert lautet TRUE, wenn eine Runtime-ID angegeben wird.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@
<target state="translated">La plataforma de destino para la que se publica. La plataforma de destino se debe especificar en el archivo de proyecto.</target>
<note />
</trans-unit>
<trans-unit id="NoSelfContainedOptionDescription">
<source>Publish your application as a framework dependent application without the .NET runtime. A supported .NET runtime must be installed to run your application.</source>
<target state="translated">Publique la aplicación como dependiente del marco de trabajo sin el entorno de ejecución .NET. Para ejecutar la aplicación, debe instalarse un entorno de ejecución .NET admitido.</target>
<note />
</trans-unit>
<trans-unit id="OutputOption">
<source>OUTPUT_DIR</source>
<target state="translated">OUTPUT_DIR</target>
Expand Down Expand Up @@ -64,18 +59,6 @@ El valor predeterminado es publicar una aplicación dependiente del marco.</targ
<target state="translated">La configuración para la que se publica. El valor predeterminado para la mayoría de los proyectos es "Debug".</target>
<note />
</trans-unit>
<trans-unit id="SelfContainAndNoSelfContainedConflict">
<source>The '--self-contained' and '--no-self-contained' options conflict with each other. Specify only one of the options.</source>
<target state="translated">Las opciones "--self-contained" y "--no-self-contained" están en conflicto entre sí. Especifique solo una de ellas.</target>
<note />
</trans-unit>
<trans-unit id="SelfContainedOptionDescription">
<source>Publish the .NET runtime with your application so the runtime doesn't need to be installed on the target machine.
The default is 'true' if a runtime identifier is specified.</source>
<target state="translated">Publique el entorno de ejecución .NET con la aplicación para que no sea necesario instalar dicho entorno en la máquina de destino.
El valor predeterminado es "true" si se especifica un identificador de entorno de ejecución.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@
<target state="translated">Framework cible pour lequel la publication est effectuée. Le framework cible doit être spécifié dans le fichier projet.</target>
<note />
</trans-unit>
<trans-unit id="NoSelfContainedOptionDescription">
<source>Publish your application as a framework dependent application without the .NET runtime. A supported .NET runtime must be installed to run your application.</source>
<target state="translated">Publiez votre application en tant qu'application dépendante du framework sans le runtime .NET. Vous devez installer un runtime .NET pris en charge pour permettre l'exécution de votre application.</target>
<note />
</trans-unit>
<trans-unit id="OutputOption">
<source>OUTPUT_DIR</source>
<target state="translated">OUTPUT_DIR</target>
Expand Down Expand Up @@ -64,18 +59,6 @@ La valeur par défaut est de publier une application dépendante du framework.</
<target state="translated">Configuration pour laquelle la publication est effectuée. La valeur par défaut pour la plupart des projets est 'Debug'.</target>
<note />
</trans-unit>
<trans-unit id="SelfContainAndNoSelfContainedConflict">
<source>The '--self-contained' and '--no-self-contained' options conflict with each other. Specify only one of the options.</source>
<target state="translated">Les options '--self-contained' et '--no-self-contained' sont en conflit. Spécifiez uniquement l'une de ces options.</target>
<note />
</trans-unit>
<trans-unit id="SelfContainedOptionDescription">
<source>Publish the .NET runtime with your application so the runtime doesn't need to be installed on the target machine.
The default is 'true' if a runtime identifier is specified.</source>
<target state="translated">Publiez le runtime .NET avec votre application pour éviter à l'utilisateur de l'installer sur la machine cible.
La valeur par défaut est 'true' si un identificateur de runtime est spécifié.</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
Loading