Skip to content

Commit 7f685ff

Browse files
authored
Make dotnet publish use Release by default in 8.0+ Projects (#29155)
2 parents 33d4e69 + d6e4e38 commit 7f685ff

File tree

53 files changed

+1646
-3162
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1646
-3162
lines changed

src/Cli/dotnet/CommonLocalizableStrings.resx

-7
Original file line numberDiff line numberDiff line change
@@ -523,10 +523,6 @@
523523
<data name="ToolSettingsUnsupportedRunner" xml:space="preserve">
524524
<value>Command '{0}' uses unsupported runner '{1}'."</value>
525525
</data>
526-
<data name="SolutionExecutableConfigurationMismatchError" xml:space="preserve">
527-
<value>Multiple executable projects in the solution contain conflicting '{0}' values. Ensure the values match. Consider using a Directory.build.props file to set all project configurations. Conflicting projects:
528-
{1}.</value>
529-
</data>
530526
<data name="ShellShimConflict" xml:space="preserve">
531527
<value>Command '{0}' conflicts with an existing command from another tool.</value>
532528
</data>
@@ -709,9 +705,6 @@ The default is 'true' if a runtime identifier is specified.</value>
709705
<data name="ResponseFileNotFound" xml:space="preserve">
710706
<value>Response file '{0}' does not exist.</value>
711707
</data>
712-
<data name="CustomConfigurationDisablesPublishAndPackReleaseProperties" xml:space="preserve">
713-
<value>A custom configuration was detected in the project '{0}', so the property '{1}' will not take effect.</value>
714-
</data>
715708
<data name="CorruptSolutionProjectFolderStructure" xml:space="preserve">
716709
<value>The solution file '{0}' is missing EndProject tags or has invalid child-parent project folder mappings around project GUID: '{1}'. Manually repair the solution or try to open and save it in Visual Studio."</value>
717710
</data>

src/Cli/dotnet/ReleasePropertyProjectLocator.cs

+181-90
Large diffs are not rendered by default.

src/Cli/dotnet/commands/dotnet-pack/PackCommand.cs

+11-4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using System.CommandLine.Parsing;
1111
using Microsoft.DotNet.Tools.Publish;
1212
using System.Linq;
13+
using System.Diagnostics;
1314

1415
namespace Microsoft.DotNet.Tools.Pack
1516
{
@@ -37,15 +38,21 @@ public static PackCommand FromParseResult(ParseResult parseResult, string msbuil
3738
var msbuildArgs = new List<string>()
3839
{
3940
"-target:pack",
40-
"--property:_IsPacking=true"
41+
"--property:_IsPacking=true" // This property will not hold true for MSBuild /t:Publish or in VS.
4142
};
4243

4344
IEnumerable<string> slnOrProjectArgs = parseResult.GetValue(PackCommandParser.SlnOrProjectArgument);
4445

4546
msbuildArgs.AddRange(parseResult.OptionValuesToBeForwarded(PackCommandParser.GetCommand()));
46-
ReleasePropertyProjectLocator projectLocator = new ReleasePropertyProjectLocator(Environment.GetEnvironmentVariable(EnvironmentVariableNames.ENABLE_PACK_RELEASE_FOR_SOLUTIONS) != null);
47-
msbuildArgs.AddRange(projectLocator.GetCustomDefaultConfigurationValueIfSpecified(parseResult, MSBuildPropertyNames.PACK_RELEASE,
48-
slnOrProjectArgs, PackCommandParser.ConfigurationOption) ?? Array.Empty<string>());
47+
48+
ReleasePropertyProjectLocator projectLocator = new ReleasePropertyProjectLocator(parseResult, MSBuildPropertyNames.PACK_RELEASE,
49+
new ReleasePropertyProjectLocator.DependentCommandOptions(
50+
parseResult.GetValue(PackCommandParser.SlnOrProjectArgument),
51+
parseResult.HasOption(PackCommandParser.ConfigurationOption) ? parseResult.GetValue(PackCommandParser.ConfigurationOption) : null
52+
)
53+
);
54+
msbuildArgs.AddRange(projectLocator.GetCustomDefaultConfigurationValueIfSpecified());
55+
4956
msbuildArgs.AddRange(slnOrProjectArgs ?? Array.Empty<string>());
5057

5158
bool noRestore = parseResult.HasOption(PackCommandParser.NoRestoreOption) || parseResult.HasOption(PackCommandParser.NoBuildOption);

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

+11-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static PublishCommand FromParseResult(ParseResult parseResult, string msb
4646
var msbuildArgs = new List<string>()
4747
{
4848
"-target:Publish",
49-
"--property:_IsPublishing=true" // This property will not hold true for MSBuild /t:Publish. VS should also inject this property when publishing in the future.
49+
"--property:_IsPublishing=true" // This property will not hold true for MSBuild /t:Publish or in VS.
5050
};
5151

5252
IEnumerable<string> slnOrProjectArgs = parseResult.GetValue(PublishCommandParser.SlnOrProjectArgument);
@@ -55,9 +55,16 @@ public static PublishCommand FromParseResult(ParseResult parseResult, string msb
5555
parseResult.HasOption(PublishCommandParser.NoSelfContainedOption));
5656

5757
msbuildArgs.AddRange(parseResult.OptionValuesToBeForwarded(PublishCommandParser.GetCommand()));
58-
ReleasePropertyProjectLocator projectLocator = new ReleasePropertyProjectLocator(Environment.GetEnvironmentVariable(EnvironmentVariableNames.ENABLE_PUBLISH_RELEASE_FOR_SOLUTIONS) != null);
59-
msbuildArgs.AddRange(projectLocator.GetCustomDefaultConfigurationValueIfSpecified(parseResult, MSBuildPropertyNames.PUBLISH_RELEASE,
60-
slnOrProjectArgs, PublishCommandParser.ConfigurationOption) ?? Array.Empty<string>());
58+
59+
ReleasePropertyProjectLocator projectLocator = new ReleasePropertyProjectLocator(parseResult, MSBuildPropertyNames.PUBLISH_RELEASE,
60+
new ReleasePropertyProjectLocator.DependentCommandOptions(
61+
parseResult.GetValue(PublishCommandParser.SlnOrProjectArgument),
62+
parseResult.HasOption(PublishCommandParser.ConfigurationOption) ? parseResult.GetValue(PublishCommandParser.ConfigurationOption) : null,
63+
parseResult.HasOption(PublishCommandParser.FrameworkOption) ? parseResult.GetValue(PublishCommandParser.FrameworkOption) : null
64+
)
65+
);
66+
msbuildArgs.AddRange(projectLocator.GetCustomDefaultConfigurationValueIfSpecified());
67+
6168
msbuildArgs.AddRange(slnOrProjectArgs ?? Array.Empty<string>());
6269

6370
bool noRestore = parseResult.HasOption(PublishCommandParser.NoRestoreOption)

src/Cli/dotnet/dotnet.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
<EmbeddedResource Update="ToolManifest\*.resx" Namespace="Microsoft.DotNet.ToolManifest" />
7575
<EmbeddedResource Update="NugetSearch\*.resx" Namespace="Microsoft.DotNet.NugetSearch" />
7676
<EmbeddedResource Update="NugetPackageDownloader\*.resx" Namespace="Microsoft.DotNet.Cli.NuGetPackageDownloader" />
77+
<EmbeddedResource Include="$(RepoRoot)src\Tasks\Common\Resources\Strings.resx" LinkBase="Resources" GenerateSource="True" Namespace="Microsoft.NET.Build.Tasks" />
7778
</ItemGroup>
7879
<ItemGroup>
7980
<ProjectReference Include="../Microsoft.DotNet.Configurer/Microsoft.DotNet.Configurer.csproj" />

src/Cli/dotnet/xlf/CommonLocalizableStrings.cs.xlf

-12
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@
4242
<target state="translated">V {0} se nenašel žádný projekt.</target>
4343
<note />
4444
</trans-unit>
45-
<trans-unit id="CustomConfigurationDisablesPublishAndPackReleaseProperties">
46-
<source>A custom configuration was detected in the project '{0}', so the property '{1}' will not take effect.</source>
47-
<target state="translated">U projektu {0} byla zjištěna vlastní konfigurace, takže vlastnost {1} se neprojeví.</target>
48-
<note />
49-
</trans-unit>
5045
<trans-unit id="DisableBuildServersOptionDescription">
5146
<source>Force the command to ignore any persistent build servers.</source>
5247
<target state="translated">Vynuťte, aby příkaz ignoroval všechny trvalé buildovací servery.</target>
@@ -202,13 +197,6 @@ Pokud se zadá identifikátor modulu runtime, výchozí hodnota je true.</target
202197
<target state="translated">Řešení</target>
203198
<note />
204199
</trans-unit>
205-
<trans-unit id="SolutionExecutableConfigurationMismatchError">
206-
<source>Multiple executable projects in the solution contain conflicting '{0}' values. Ensure the values match. Consider using a Directory.build.props file to set all project configurations. Conflicting projects:
207-
{1}.</source>
208-
<target state="translated">Několik spustitelných projektů v řešení obsahuje konfliktní hodnoty {0}. Ujistěte se, že se hodnoty shodují. Zvažte použití souboru Directory.build.props k nastavení všech konfigurací projektu. Konfliktní projekty:
209-
{1}.</target>
210-
<note />
211-
</trans-unit>
212200
<trans-unit id="SolutionFile">
213201
<source>Solution file</source>
214202
<target state="translated">Soubor řešení</target>

src/Cli/dotnet/xlf/CommonLocalizableStrings.de.xlf

-12
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@
4242
<target state="translated">In "{0}" wurde kein Projekt gefunden.</target>
4343
<note />
4444
</trans-unit>
45-
<trans-unit id="CustomConfigurationDisablesPublishAndPackReleaseProperties">
46-
<source>A custom configuration was detected in the project '{0}', so the property '{1}' will not take effect.</source>
47-
<target state="translated">Im Projekt „{0}“ wurde eine benutzerdefinierte Konfiguration erkannt, somit wird die Eigenschaft „{1}“ nicht wirksam.</target>
48-
<note />
49-
</trans-unit>
5045
<trans-unit id="DisableBuildServersOptionDescription">
5146
<source>Force the command to ignore any persistent build servers.</source>
5247
<target state="translated">Erzwingen Sie, dass der Befehl alle persistenten Buildserver ignoriert.</target>
@@ -202,13 +197,6 @@ Der Standardwert lautet TRUE, wenn eine Runtime-ID angegeben wird.</target>
202197
<target state="translated">Projektmappe</target>
203198
<note />
204199
</trans-unit>
205-
<trans-unit id="SolutionExecutableConfigurationMismatchError">
206-
<source>Multiple executable projects in the solution contain conflicting '{0}' values. Ensure the values match. Consider using a Directory.build.props file to set all project configurations. Conflicting projects:
207-
{1}.</source>
208-
<target state="translated">Mehrere ausführbare Projekte in der Lösung enthalten widersprüchliche Werte für „{0}“. Stellen Sie sicher, dass die Werte übereinstimmen. Erwägen Sie die Verwendung einer Datei „Directory.build.props“, um alle Projektkonfigurationen festzulegen. In Konflikt stehende Projekte:
209-
{1}.</target>
210-
<note />
211-
</trans-unit>
212200
<trans-unit id="SolutionFile">
213201
<source>Solution file</source>
214202
<target state="translated">Projektmappendatei</target>

src/Cli/dotnet/xlf/CommonLocalizableStrings.es.xlf

-12
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@
4242
<target state="translated">No se encuentra ningún proyecto en "{0}".</target>
4343
<note />
4444
</trans-unit>
45-
<trans-unit id="CustomConfigurationDisablesPublishAndPackReleaseProperties">
46-
<source>A custom configuration was detected in the project '{0}', so the property '{1}' will not take effect.</source>
47-
<target state="translated">Se detectó una configuración personalizada en el proyecto "{0}", por lo que la propiedad "{1}" no surtirá efecto.</target>
48-
<note />
49-
</trans-unit>
5045
<trans-unit id="DisableBuildServersOptionDescription">
5146
<source>Force the command to ignore any persistent build servers.</source>
5247
<target state="translated">Fuerce el comando para omitir los servidores de compilación persistentes.</target>
@@ -202,13 +197,6 @@ El valor predeterminado es "true" si se especifica un identificador de entorno d
202197
<target state="translated">Solución</target>
203198
<note />
204199
</trans-unit>
205-
<trans-unit id="SolutionExecutableConfigurationMismatchError">
206-
<source>Multiple executable projects in the solution contain conflicting '{0}' values. Ensure the values match. Consider using a Directory.build.props file to set all project configurations. Conflicting projects:
207-
{1}.</source>
208-
<target state="translated">Varios proyectos ejecutables de la solución contienen valores "{0}" en conflicto. Asegúrese de que los valores coinciden. Considere la posibilidad de usar un archivo Directory.build.props para establecer todas las configuraciones del proyecto. Proyectos en conflicto:
209-
{1}.</target>
210-
<note />
211-
</trans-unit>
212200
<trans-unit id="SolutionFile">
213201
<source>Solution file</source>
214202
<target state="translated">Archivo de solución</target>

src/Cli/dotnet/xlf/CommonLocalizableStrings.fr.xlf

-12
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@
4242
<target state="translated">Projet introuvable dans '{0}'.</target>
4343
<note />
4444
</trans-unit>
45-
<trans-unit id="CustomConfigurationDisablesPublishAndPackReleaseProperties">
46-
<source>A custom configuration was detected in the project '{0}', so the property '{1}' will not take effect.</source>
47-
<target state="translated">Une configuration personnalisée a été détectée dans le '{0}' du projet, la propriété '{1}' ne sera donc pas prise en compte.</target>
48-
<note />
49-
</trans-unit>
5045
<trans-unit id="DisableBuildServersOptionDescription">
5146
<source>Force the command to ignore any persistent build servers.</source>
5247
<target state="translated">Forcez la commande à ignorer tous les serveurs de build persistants.</target>
@@ -202,13 +197,6 @@ La valeur par défaut est 'true' si un identificateur de runtime est spécifié.
202197
<target state="translated">Solution</target>
203198
<note />
204199
</trans-unit>
205-
<trans-unit id="SolutionExecutableConfigurationMismatchError">
206-
<source>Multiple executable projects in the solution contain conflicting '{0}' values. Ensure the values match. Consider using a Directory.build.props file to set all project configurations. Conflicting projects:
207-
{1}.</source>
208-
<target state="translated">Plusieurs projets exécutables de la solution contiennent des valeurs de '{0}' en conflit. Vérifiez que les valeurs correspondent. Utilisez un fichier Directory.build.props pour définir toutes les configurations de projet. Projets en conflit :
209-
{1}.</target>
210-
<note />
211-
</trans-unit>
212200
<trans-unit id="SolutionFile">
213201
<source>Solution file</source>
214202
<target state="translated">Fichier solution</target>

src/Cli/dotnet/xlf/CommonLocalizableStrings.it.xlf

-12
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@
4242
<target state="translated">Non è stato trovato alcun progetto in `{0}`.</target>
4343
<note />
4444
</trans-unit>
45-
<trans-unit id="CustomConfigurationDisablesPublishAndPackReleaseProperties">
46-
<source>A custom configuration was detected in the project '{0}', so the property '{1}' will not take effect.</source>
47-
<target state="translated">È stata rilevata una configurazione personalizzata nel progetto '{0}', quindi la proprietà '{1}' non avrà effetto.</target>
48-
<note />
49-
</trans-unit>
5045
<trans-unit id="DisableBuildServersOptionDescription">
5146
<source>Force the command to ignore any persistent build servers.</source>
5247
<target state="translated">Forza il comando a ignorare tutti i server di compilazione persistenti.</target>
@@ -202,13 +197,6 @@ L'impostazione predefinita è 'true' se si specifica un identificatore di runtim
202197
<target state="translated">Soluzione</target>
203198
<note />
204199
</trans-unit>
205-
<trans-unit id="SolutionExecutableConfigurationMismatchError">
206-
<source>Multiple executable projects in the solution contain conflicting '{0}' values. Ensure the values match. Consider using a Directory.build.props file to set all project configurations. Conflicting projects:
207-
{1}.</source>
208-
<target state="translated">Più progetti eseguibili nella soluzione contengono valori '{0}' in conflitto. Verificare che i valori corrispondano. Prova a usare un file Directory.build.props per impostare tutte le configurazioni del progetto. Progetti in conflitto:
209-
{1}.</target>
210-
<note />
211-
</trans-unit>
212200
<trans-unit id="SolutionFile">
213201
<source>Solution file</source>
214202
<target state="translated">File di soluzione</target>

src/Cli/dotnet/xlf/CommonLocalizableStrings.ja.xlf

-12
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@
4242
<target state="translated">`{0}` にプロジェクトが見つかりませんでした。</target>
4343
<note />
4444
</trans-unit>
45-
<trans-unit id="CustomConfigurationDisablesPublishAndPackReleaseProperties">
46-
<source>A custom configuration was detected in the project '{0}', so the property '{1}' will not take effect.</source>
47-
<target state="translated">プロジェクト '{0}' でカスタム構成が検出されたため、プロパティ '{1}' は有効になりません。</target>
48-
<note />
49-
</trans-unit>
5045
<trans-unit id="DisableBuildServersOptionDescription">
5146
<source>Force the command to ignore any persistent build servers.</source>
5247
<target state="translated">永続的なビルド サーバーがそのコマンドで無視されるようにします。</target>
@@ -202,13 +197,6 @@ The default is 'true' if a runtime identifier is specified.</source>
202197
<target state="translated">ソリューション</target>
203198
<note />
204199
</trans-unit>
205-
<trans-unit id="SolutionExecutableConfigurationMismatchError">
206-
<source>Multiple executable projects in the solution contain conflicting '{0}' values. Ensure the values match. Consider using a Directory.build.props file to set all project configurations. Conflicting projects:
207-
{1}.</source>
208-
<target state="translated">ソリューション内の複数の実行可能プロジェクトに、競合する '{0}' 値が含まれています。値が一致するようにしてください。Directory.build.props ファイルを使用して、すべてのプロジェクト構成を設定することを検討してください。競合するプロジェクト:
209-
{1}。</target>
210-
<note />
211-
</trans-unit>
212200
<trans-unit id="SolutionFile">
213201
<source>Solution file</source>
214202
<target state="translated">ソリューション ファイル</target>

src/Cli/dotnet/xlf/CommonLocalizableStrings.ko.xlf

-12
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@
4242
<target state="translated">'{0}'에서 프로젝트를 찾을 수 없습니다.</target>
4343
<note />
4444
</trans-unit>
45-
<trans-unit id="CustomConfigurationDisablesPublishAndPackReleaseProperties">
46-
<source>A custom configuration was detected in the project '{0}', so the property '{1}' will not take effect.</source>
47-
<target state="translated">'{0}' 프로젝트에서 사용자 지정 구성이 검색되었으므로 '{1}' 속성이 적용되지 않습니다.</target>
48-
<note />
49-
</trans-unit>
5045
<trans-unit id="DisableBuildServersOptionDescription">
5146
<source>Force the command to ignore any persistent build servers.</source>
5247
<target state="translated">모든 영구 빌드 서버를 무시하도록 명령을 강제 실행합니다.</target>
@@ -202,13 +197,6 @@ The default is 'true' if a runtime identifier is specified.</source>
202197
<target state="translated">솔루션</target>
203198
<note />
204199
</trans-unit>
205-
<trans-unit id="SolutionExecutableConfigurationMismatchError">
206-
<source>Multiple executable projects in the solution contain conflicting '{0}' values. Ensure the values match. Consider using a Directory.build.props file to set all project configurations. Conflicting projects:
207-
{1}.</source>
208-
<target state="translated">솔루션의 여러 실행 가능한 프로젝트에 충돌하는 '{0}' 값이 포함되어 있습니다. 값이 일치하는지 확인하세요. Directory.build.props 파일을 사용하여 모든 프로젝트 구성을 설정하는 것이 좋습니다. 충돌하는 프로젝트:
209-
{1}.</target>
210-
<note />
211-
</trans-unit>
212200
<trans-unit id="SolutionFile">
213201
<source>Solution file</source>
214202
<target state="translated">솔루션 파일</target>

0 commit comments

Comments
 (0)