Skip to content

Commit 9c221bd

Browse files
committed
Add build self contained options
1 parent 82ba81a commit 9c221bd

32 files changed

+192
-171
lines changed

src/Cli/dotnet/CommonLocalizableStrings.resx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,4 +674,11 @@ setx PATH "%PATH%;{0}"
674674
<data name="CommandPrereleaseOptionDescription" xml:space="preserve">
675675
<value>Allows prerelease packages to be installed.</value>
676676
</data>
677-
</root>
677+
<data name="SelfContainedOptionDescription" xml:space="preserve">
678+
<value>Publish the .NET runtime with your application so the runtime doesn't need to be installed on the target machine.
679+
The default is 'true' if a runtime identifier is specified.</value>
680+
</data>
681+
<data name="NoSelfContainedOptionDescription" xml:space="preserve">
682+
<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>
683+
</data>
684+
</root>

src/Cli/dotnet/CommonOptions.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,18 @@ public static Option InteractiveOption() =>
9393

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

96+
public static Option SelfContainedOption() =>
97+
new ForwardedOption<bool>(
98+
"--self-contained",
99+
CommonLocalizableStrings.SelfContainedOptionDescription)
100+
.ForwardAsSingle(o => $"-property:SelfContained={o}");
101+
102+
public static Option NoSelfContainedOption() =>
103+
new ForwardedOption<bool>(
104+
"--no-self-contained",
105+
CommonLocalizableStrings.NoSelfContainedOptionDescription)
106+
.ForwardAs("-property:SelfContained=false");
107+
96108
public static bool VerbosityIsDetailedOrDiagnostic(this VerbosityOptions verbosity)
97109
{
98110
return verbosity.Equals(VerbosityOptions.diag) ||

src/Cli/dotnet/commands/dotnet-build/BuildCommand.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using Parser = Microsoft.DotNet.Cli.Parser;
88
using System.CommandLine.Parsing;
99
using System;
10-
using System.Linq;
1110

1211
namespace Microsoft.DotNet.Tools.Build
1312
{
@@ -33,6 +32,12 @@ public static BuildCommand FromArgs(string[] args, string msbuildPath = null)
3332

3433
parseResult.ShowHelpOrErrorIfAppropriate();
3534

35+
if (parseResult.HasOption(BuildCommandParser.SelfContainedOption) &&
36+
parseResult.HasOption(BuildCommandParser.NoSelfContainedOption))
37+
{
38+
throw new GracefulException(Publish.LocalizableStrings.SelfContainAndNoSelfContainedConflict);
39+
}
40+
3641
msbuildArgs.Add($"-consoleloggerparameters:Summary");
3742

3843
if (parseResult.HasOption(BuildCommandParser.NoIncrementalOption))

src/Cli/dotnet/commands/dotnet-build/BuildCommandParser.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ internal static class BuildCommandParser
3131

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

34+
public static readonly Option SelfContainedOption = CommonOptions.SelfContainedOption();
35+
36+
public static readonly Option NoSelfContainedOption = CommonOptions.NoSelfContainedOption();
37+
3438
public static Command GetCommand()
3539
{
3640
var command = new Command("build", LocalizableStrings.AppFullName);
@@ -49,6 +53,8 @@ public static Command GetCommand()
4953
command.AddOption(NoIncrementalOption);
5054
command.AddOption(NoDependenciesOption);
5155
command.AddOption(NoLogoOption);
56+
command.AddOption(SelfContainedOption);
57+
command.AddOption(NoSelfContainedOption);
5258

5359
return command;
5460
}

src/Cli/dotnet/commands/dotnet-publish/LocalizableStrings.resx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,6 @@
135135
<data name="ManifestOptionDescription" xml:space="preserve">
136136
<value>The path to a target manifest file that contains the list of packages to be excluded from the publish step.</value>
137137
</data>
138-
<data name="SelfContainedOptionDescription" xml:space="preserve">
139-
<value>Publish the .NET runtime with your application so the runtime doesn't need to be installed on the target machine.
140-
The default is 'true' if a runtime identifier is specified.</value>
141-
</data>
142138
<data name="NoBuildOptionDescription" xml:space="preserve">
143139
<value>Do not build the project before publishing. Implies --no-restore.</value>
144140
</data>
@@ -155,9 +151,6 @@ The default is to publish a framework-dependent application.</value>
155151
<data name="CmdNoLogo" xml:space="preserve">
156152
<value>Do not display the startup banner or the copyright message.</value>
157153
</data>
158-
<data name="NoSelfContainedOptionDescription" xml:space="preserve">
159-
<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>
160-
</data>
161154
<data name="SelfContainAndNoSelfContainedConflict" xml:space="preserve">
162155
<value>The '--self-contained' and '--no-self-contained' options conflict with each other. Specify only one of the options.</value>
163156
</data>

src/Cli/dotnet/commands/dotnet-publish/PublishCommandParser.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,15 @@ internal static class PublishCommandParser
3131
public static readonly Option NoBuildOption = new ForwardedOption<bool>("--no-build", LocalizableStrings.NoBuildOptionDescription)
3232
.ForwardAs("-property:NoBuild=true");
3333

34-
public static readonly Option SelfContainedOption = new ForwardedOption<bool>("--self-contained", LocalizableStrings.SelfContainedOptionDescription)
35-
.ForwardAsSingle(o => $"-property:SelfContained={o}");
36-
37-
public static readonly Option NoSelfContainedOption = new ForwardedOption<bool>("--no-self-contained", LocalizableStrings.NoSelfContainedOptionDescription)
38-
.ForwardAs("-property:SelfContained=false");
39-
4034
public static readonly Option NoLogoOption = new ForwardedOption<bool>("--nologo", LocalizableStrings.CmdNoLogo)
4135
.ForwardAs("-nologo");
4236

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

39+
public static readonly Option SelfContainedOption = CommonOptions.SelfContainedOption();
40+
41+
public static readonly Option NoSelfContainedOption = CommonOptions.NoSelfContainedOption();
42+
4543
public static Command GetCommand()
4644
{
4745
var command = new Command("publish", LocalizableStrings.AppDescription);

src/Cli/dotnet/commands/dotnet-publish/xlf/LocalizableStrings.cs.xlf

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@
2222
<target state="translated">Cílová architektura pro publikování. Cílová architektura musí být zadaná v souboru projektu.</target>
2323
<note />
2424
</trans-unit>
25-
<trans-unit id="NoSelfContainedOptionDescription">
26-
<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>
27-
<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>
28-
<note />
29-
</trans-unit>
3025
<trans-unit id="OutputOption">
3126
<source>OUTPUT_DIR</source>
3227
<target state="translated">OUTPUT_DIR</target>
@@ -69,13 +64,6 @@ Ve výchozím nastavení je publikována aplikace závislá na architektuře.</t
6964
<target state="translated">Možnosti --self-contained a --no-self-contained jsou vzájemně konfliktní. Zadejte pouze jednu z nich.</target>
7065
<note />
7166
</trans-unit>
72-
<trans-unit id="SelfContainedOptionDescription">
73-
<source>Publish the .NET runtime with your application so the runtime doesn't need to be installed on the target machine.
74-
The default is 'true' if a runtime identifier is specified.</source>
75-
<target state="translated">Publikujte se svou aplikací modul runtime pro .NET, aby ho nebylo nutné instalovat na cílovém počítači.
76-
Pokud se zadá identifikátor modulu runtime, výchozí hodnota je true.</target>
77-
<note />
78-
</trans-unit>
7967
</body>
8068
</file>
8169
</xliff>

src/Cli/dotnet/commands/dotnet-publish/xlf/LocalizableStrings.de.xlf

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@
2222
<target state="translated">Das Zielframework für die Veröffentlichung. Das Zielframework muss in der Projektdatei angegeben werden.</target>
2323
<note />
2424
</trans-unit>
25-
<trans-unit id="NoSelfContainedOptionDescription">
26-
<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>
27-
<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>
28-
<note />
29-
</trans-unit>
3025
<trans-unit id="OutputOption">
3126
<source>OUTPUT_DIR</source>
3227
<target state="translated">OUTPUT_DIR</target>
@@ -69,13 +64,6 @@ Standardmäßig wird eine Framework-abhängige Anwendung veröffentlicht.</targe
6964
<target state="translated">Die Optionen "--self-contained" und "--no-self-contained" stehen in Konflikt zueinander. Geben Sie nur eine der Optionen an.</target>
7065
<note />
7166
</trans-unit>
72-
<trans-unit id="SelfContainedOptionDescription">
73-
<source>Publish the .NET runtime with your application so the runtime doesn't need to be installed on the target machine.
74-
The default is 'true' if a runtime identifier is specified.</source>
75-
<target state="translated">Hiermit wird die .NET-Runtime mit Ihrer Anwendung veröffentlicht, sodass die Runtime nicht auf dem Zielcomputer installiert werden muss.
76-
Der Standardwert lautet TRUE, wenn eine Runtime-ID angegeben wird.</target>
77-
<note />
78-
</trans-unit>
7967
</body>
8068
</file>
8169
</xliff>

src/Cli/dotnet/commands/dotnet-publish/xlf/LocalizableStrings.es.xlf

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@
2222
<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>
2323
<note />
2424
</trans-unit>
25-
<trans-unit id="NoSelfContainedOptionDescription">
26-
<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>
27-
<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>
28-
<note />
29-
</trans-unit>
3025
<trans-unit id="OutputOption">
3126
<source>OUTPUT_DIR</source>
3227
<target state="translated">OUTPUT_DIR</target>
@@ -69,13 +64,6 @@ El valor predeterminado es publicar una aplicación dependiente del marco.</targ
6964
<target state="translated">Las opciones "--self-contained" y "--no-self-contained" están en conflicto entre sí. Especifique solo una de ellas.</target>
7065
<note />
7166
</trans-unit>
72-
<trans-unit id="SelfContainedOptionDescription">
73-
<source>Publish the .NET runtime with your application so the runtime doesn't need to be installed on the target machine.
74-
The default is 'true' if a runtime identifier is specified.</source>
75-
<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.
76-
El valor predeterminado es "true" si se especifica un identificador de entorno de ejecución.</target>
77-
<note />
78-
</trans-unit>
7967
</body>
8068
</file>
8169
</xliff>

src/Cli/dotnet/commands/dotnet-publish/xlf/LocalizableStrings.fr.xlf

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@
2222
<target state="translated">Framework cible pour lequel la publication est effectuée. Le framework cible doit être spécifié dans le fichier projet.</target>
2323
<note />
2424
</trans-unit>
25-
<trans-unit id="NoSelfContainedOptionDescription">
26-
<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>
27-
<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>
28-
<note />
29-
</trans-unit>
3025
<trans-unit id="OutputOption">
3126
<source>OUTPUT_DIR</source>
3227
<target state="translated">OUTPUT_DIR</target>
@@ -69,13 +64,6 @@ La valeur par défaut est de publier une application dépendante du framework.</
6964
<target state="translated">Les options '--self-contained' et '--no-self-contained' sont en conflit. Spécifiez uniquement l'une de ces options.</target>
7065
<note />
7166
</trans-unit>
72-
<trans-unit id="SelfContainedOptionDescription">
73-
<source>Publish the .NET runtime with your application so the runtime doesn't need to be installed on the target machine.
74-
The default is 'true' if a runtime identifier is specified.</source>
75-
<target state="translated">Publiez le runtime .NET avec votre application pour éviter à l'utilisateur de l'installer sur la machine cible.
76-
La valeur par défaut est 'true' si un identificateur de runtime est spécifié.</target>
77-
<note />
78-
</trans-unit>
7967
</body>
8068
</file>
8169
</xliff>

0 commit comments

Comments
 (0)