diff --git a/src/Tasks/Common/Resources/Strings.resx b/src/Tasks/Common/Resources/Strings.resx index 923913bd1f06..dd106b1011e0 100644 --- a/src/Tasks/Common/Resources/Strings.resx +++ b/src/Tasks/Common/Resources/Strings.resx @@ -1014,5 +1014,9 @@ You may need to build the project on another operating system or architecture, o NETSDK1234: RoslynCompilerType 'Framework' is deprecated and will be removed in a future version. Please refer to {0} for more information. {StrBegins="NETSDK1234: "}{Locked="RoslynCompilerType"}{Locked="Framework"}{Locked="{0}"} - + + NETSDK1235: Setting the PlatformTarget property to '{0}' is not recommended for modern .NET applications. The PlatformTarget property is a legacy setting from .NET Framework and has no effect in modern .NET. Consider removing PlatformTarget or setting it to 'AnyCPU'. + {StrBegins="NETSDK1235: "}{Locked="PlatformTarget"}{Locked="AnyCPU"} + + diff --git a/src/Tasks/Common/Resources/xlf/Strings.cs.xlf b/src/Tasks/Common/Resources/xlf/Strings.cs.xlf index e2843aabc896..4d505eabc017 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.cs.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.cs.xlf @@ -776,6 +776,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1174: Zástupný symbol {StrBegins="NETSDK1174: "} - This string is not used here, but is a placeholder for the error code, which is used by the "dotnet run" command. + + NETSDK1235: Setting the PlatformTarget property to '{0}' is not recommended for modern .NET applications. The PlatformTarget property is a legacy setting from .NET Framework and has no effect in modern .NET. Consider removing PlatformTarget or setting it to 'AnyCPU'. + NETSDK1235: Setting the PlatformTarget property to '{0}' is not recommended for modern .NET applications. The PlatformTarget property is a legacy setting from .NET Framework and has no effect in modern .NET. Consider removing PlatformTarget or setting it to 'AnyCPU'. + {StrBegins="NETSDK1235: "}{Locked="PlatformTarget"}{Locked="AnyCPU"} + NETSDK1189: Prefer32Bit is not supported and has no effect for netcoreapp target. NETSDK1189: Prefer32Bit se nepodporuje a nemá žádný vliv na cíl netcoreapp. diff --git a/src/Tasks/Common/Resources/xlf/Strings.de.xlf b/src/Tasks/Common/Resources/xlf/Strings.de.xlf index 739552850863..afffb69859b9 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.de.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.de.xlf @@ -776,6 +776,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1174: Platzhalter {StrBegins="NETSDK1174: "} - This string is not used here, but is a placeholder for the error code, which is used by the "dotnet run" command. + + NETSDK1235: Setting the PlatformTarget property to '{0}' is not recommended for modern .NET applications. The PlatformTarget property is a legacy setting from .NET Framework and has no effect in modern .NET. Consider removing PlatformTarget or setting it to 'AnyCPU'. + NETSDK1235: Setting the PlatformTarget property to '{0}' is not recommended for modern .NET applications. The PlatformTarget property is a legacy setting from .NET Framework and has no effect in modern .NET. Consider removing PlatformTarget or setting it to 'AnyCPU'. + {StrBegins="NETSDK1235: "}{Locked="PlatformTarget"}{Locked="AnyCPU"} + NETSDK1189: Prefer32Bit is not supported and has no effect for netcoreapp target. NETSDK1189: Prefer32Bit wird nicht unterstützt und hat keine Auswirkungen auf das netcoreapp-Ziel. diff --git a/src/Tasks/Common/Resources/xlf/Strings.es.xlf b/src/Tasks/Common/Resources/xlf/Strings.es.xlf index 05d896c73eec..eecc10cde1aa 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.es.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.es.xlf @@ -776,6 +776,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1174: Marcador de posición {StrBegins="NETSDK1174: "} - This string is not used here, but is a placeholder for the error code, which is used by the "dotnet run" command. + + NETSDK1235: Setting the PlatformTarget property to '{0}' is not recommended for modern .NET applications. The PlatformTarget property is a legacy setting from .NET Framework and has no effect in modern .NET. Consider removing PlatformTarget or setting it to 'AnyCPU'. + NETSDK1235: Setting the PlatformTarget property to '{0}' is not recommended for modern .NET applications. The PlatformTarget property is a legacy setting from .NET Framework and has no effect in modern .NET. Consider removing PlatformTarget or setting it to 'AnyCPU'. + {StrBegins="NETSDK1235: "}{Locked="PlatformTarget"}{Locked="AnyCPU"} + NETSDK1189: Prefer32Bit is not supported and has no effect for netcoreapp target. NETSDK1189: Prefer32Bit no se admite y no tiene efecto para el destino netcoreapp. diff --git a/src/Tasks/Common/Resources/xlf/Strings.fr.xlf b/src/Tasks/Common/Resources/xlf/Strings.fr.xlf index 1e2cb7d74a04..2a8a4ff28435 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.fr.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.fr.xlf @@ -776,6 +776,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1174: Espace réservé {StrBegins="NETSDK1174: "} - This string is not used here, but is a placeholder for the error code, which is used by the "dotnet run" command. + + NETSDK1235: Setting the PlatformTarget property to '{0}' is not recommended for modern .NET applications. The PlatformTarget property is a legacy setting from .NET Framework and has no effect in modern .NET. Consider removing PlatformTarget or setting it to 'AnyCPU'. + NETSDK1235: Setting the PlatformTarget property to '{0}' is not recommended for modern .NET applications. The PlatformTarget property is a legacy setting from .NET Framework and has no effect in modern .NET. Consider removing PlatformTarget or setting it to 'AnyCPU'. + {StrBegins="NETSDK1235: "}{Locked="PlatformTarget"}{Locked="AnyCPU"} + NETSDK1189: Prefer32Bit is not supported and has no effect for netcoreapp target. NETSDK1189: Prefer32Bit n’est pas pris en charge et n’a aucun effet pour la cible netcoreapp. diff --git a/src/Tasks/Common/Resources/xlf/Strings.it.xlf b/src/Tasks/Common/Resources/xlf/Strings.it.xlf index 79345cbc5e59..ae4e32206d29 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.it.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.it.xlf @@ -776,6 +776,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1174: Placeholder {StrBegins="NETSDK1174: "} - This string is not used here, but is a placeholder for the error code, which is used by the "dotnet run" command. + + NETSDK1235: Setting the PlatformTarget property to '{0}' is not recommended for modern .NET applications. The PlatformTarget property is a legacy setting from .NET Framework and has no effect in modern .NET. Consider removing PlatformTarget or setting it to 'AnyCPU'. + NETSDK1235: Setting the PlatformTarget property to '{0}' is not recommended for modern .NET applications. The PlatformTarget property is a legacy setting from .NET Framework and has no effect in modern .NET. Consider removing PlatformTarget or setting it to 'AnyCPU'. + {StrBegins="NETSDK1235: "}{Locked="PlatformTarget"}{Locked="AnyCPU"} + NETSDK1189: Prefer32Bit is not supported and has no effect for netcoreapp target. NETSDK1189: Prefer32Bit non è supportato e non ha alcun effetto per la destinazione netcoreapp. diff --git a/src/Tasks/Common/Resources/xlf/Strings.ja.xlf b/src/Tasks/Common/Resources/xlf/Strings.ja.xlf index d59ebf7e4b24..4b8a76d45dfe 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.ja.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.ja.xlf @@ -776,6 +776,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1174: プレースホルダー {StrBegins="NETSDK1174: "} - This string is not used here, but is a placeholder for the error code, which is used by the "dotnet run" command. + + NETSDK1235: Setting the PlatformTarget property to '{0}' is not recommended for modern .NET applications. The PlatformTarget property is a legacy setting from .NET Framework and has no effect in modern .NET. Consider removing PlatformTarget or setting it to 'AnyCPU'. + NETSDK1235: Setting the PlatformTarget property to '{0}' is not recommended for modern .NET applications. The PlatformTarget property is a legacy setting from .NET Framework and has no effect in modern .NET. Consider removing PlatformTarget or setting it to 'AnyCPU'. + {StrBegins="NETSDK1235: "}{Locked="PlatformTarget"}{Locked="AnyCPU"} + NETSDK1189: Prefer32Bit is not supported and has no effect for netcoreapp target. NETSDK1189: Prefer32Bit はサポートされておらず、netcoreapp ターゲットには影響しません。 diff --git a/src/Tasks/Common/Resources/xlf/Strings.ko.xlf b/src/Tasks/Common/Resources/xlf/Strings.ko.xlf index 5d65dcc1a4f9..6790fe226552 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.ko.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.ko.xlf @@ -776,6 +776,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1174: 자리 표시자 {StrBegins="NETSDK1174: "} - This string is not used here, but is a placeholder for the error code, which is used by the "dotnet run" command. + + NETSDK1235: Setting the PlatformTarget property to '{0}' is not recommended for modern .NET applications. The PlatformTarget property is a legacy setting from .NET Framework and has no effect in modern .NET. Consider removing PlatformTarget or setting it to 'AnyCPU'. + NETSDK1235: Setting the PlatformTarget property to '{0}' is not recommended for modern .NET applications. The PlatformTarget property is a legacy setting from .NET Framework and has no effect in modern .NET. Consider removing PlatformTarget or setting it to 'AnyCPU'. + {StrBegins="NETSDK1235: "}{Locked="PlatformTarget"}{Locked="AnyCPU"} + NETSDK1189: Prefer32Bit is not supported and has no effect for netcoreapp target. NETSDK1189: Prefer32Bit는 지원되지 않으며 netcoreapp 대상에는 영향을 주지 않습니다. diff --git a/src/Tasks/Common/Resources/xlf/Strings.pl.xlf b/src/Tasks/Common/Resources/xlf/Strings.pl.xlf index ad7d52f9f803..5b92703d0aef 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.pl.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.pl.xlf @@ -776,6 +776,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1174: symbol zastępczy {StrBegins="NETSDK1174: "} - This string is not used here, but is a placeholder for the error code, which is used by the "dotnet run" command. + + NETSDK1235: Setting the PlatformTarget property to '{0}' is not recommended for modern .NET applications. The PlatformTarget property is a legacy setting from .NET Framework and has no effect in modern .NET. Consider removing PlatformTarget or setting it to 'AnyCPU'. + NETSDK1235: Setting the PlatformTarget property to '{0}' is not recommended for modern .NET applications. The PlatformTarget property is a legacy setting from .NET Framework and has no effect in modern .NET. Consider removing PlatformTarget or setting it to 'AnyCPU'. + {StrBegins="NETSDK1235: "}{Locked="PlatformTarget"}{Locked="AnyCPU"} + NETSDK1189: Prefer32Bit is not supported and has no effect for netcoreapp target. NETSDK1189: element Prefer32Bit nie jest obsługiwany i nie ma wpływu na element docelowy netcoreapp. diff --git a/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf b/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf index 2d944e7b5097..c5fa9610f9f2 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf @@ -776,6 +776,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1174: Espaço reservado {StrBegins="NETSDK1174: "} - This string is not used here, but is a placeholder for the error code, which is used by the "dotnet run" command. + + NETSDK1235: Setting the PlatformTarget property to '{0}' is not recommended for modern .NET applications. The PlatformTarget property is a legacy setting from .NET Framework and has no effect in modern .NET. Consider removing PlatformTarget or setting it to 'AnyCPU'. + NETSDK1235: Setting the PlatformTarget property to '{0}' is not recommended for modern .NET applications. The PlatformTarget property is a legacy setting from .NET Framework and has no effect in modern .NET. Consider removing PlatformTarget or setting it to 'AnyCPU'. + {StrBegins="NETSDK1235: "}{Locked="PlatformTarget"}{Locked="AnyCPU"} + NETSDK1189: Prefer32Bit is not supported and has no effect for netcoreapp target. NETSDK1189: Prefer32Bit não é suportado e não tem efeito para o destino netcoreapp. diff --git a/src/Tasks/Common/Resources/xlf/Strings.ru.xlf b/src/Tasks/Common/Resources/xlf/Strings.ru.xlf index 8c38a2f4519c..67364aed2724 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.ru.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.ru.xlf @@ -776,6 +776,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1174: заполнитель {StrBegins="NETSDK1174: "} - This string is not used here, but is a placeholder for the error code, which is used by the "dotnet run" command. + + NETSDK1235: Setting the PlatformTarget property to '{0}' is not recommended for modern .NET applications. The PlatformTarget property is a legacy setting from .NET Framework and has no effect in modern .NET. Consider removing PlatformTarget or setting it to 'AnyCPU'. + NETSDK1235: Setting the PlatformTarget property to '{0}' is not recommended for modern .NET applications. The PlatformTarget property is a legacy setting from .NET Framework and has no effect in modern .NET. Consider removing PlatformTarget or setting it to 'AnyCPU'. + {StrBegins="NETSDK1235: "}{Locked="PlatformTarget"}{Locked="AnyCPU"} + NETSDK1189: Prefer32Bit is not supported and has no effect for netcoreapp target. NETSDK1189: Prefer32Bit не поддерживается и не оказывает влияния на целевой объект netcoreapp. diff --git a/src/Tasks/Common/Resources/xlf/Strings.tr.xlf b/src/Tasks/Common/Resources/xlf/Strings.tr.xlf index a8e1b13f931a..8b8b705c45ad 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.tr.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.tr.xlf @@ -776,6 +776,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1174: Yer tutucu {StrBegins="NETSDK1174: "} - This string is not used here, but is a placeholder for the error code, which is used by the "dotnet run" command. + + NETSDK1235: Setting the PlatformTarget property to '{0}' is not recommended for modern .NET applications. The PlatformTarget property is a legacy setting from .NET Framework and has no effect in modern .NET. Consider removing PlatformTarget or setting it to 'AnyCPU'. + NETSDK1235: Setting the PlatformTarget property to '{0}' is not recommended for modern .NET applications. The PlatformTarget property is a legacy setting from .NET Framework and has no effect in modern .NET. Consider removing PlatformTarget or setting it to 'AnyCPU'. + {StrBegins="NETSDK1235: "}{Locked="PlatformTarget"}{Locked="AnyCPU"} + NETSDK1189: Prefer32Bit is not supported and has no effect for netcoreapp target. NETSDK1189: Prefer32Bit desteklenmez ve netcoreapp hedefi için hiçbir etkisi yoktur. diff --git a/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf b/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf index 05fa79d313cf..6272a56caae8 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf @@ -776,6 +776,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1174: 占位符 {StrBegins="NETSDK1174: "} - This string is not used here, but is a placeholder for the error code, which is used by the "dotnet run" command. + + NETSDK1235: Setting the PlatformTarget property to '{0}' is not recommended for modern .NET applications. The PlatformTarget property is a legacy setting from .NET Framework and has no effect in modern .NET. Consider removing PlatformTarget or setting it to 'AnyCPU'. + NETSDK1235: Setting the PlatformTarget property to '{0}' is not recommended for modern .NET applications. The PlatformTarget property is a legacy setting from .NET Framework and has no effect in modern .NET. Consider removing PlatformTarget or setting it to 'AnyCPU'. + {StrBegins="NETSDK1235: "}{Locked="PlatformTarget"}{Locked="AnyCPU"} + NETSDK1189: Prefer32Bit is not supported and has no effect for netcoreapp target. NETSDK1189: Prefer32Bit 不受支持,对 netcoreapp 目标无效。 diff --git a/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf b/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf index 6ed44c157d07..87948580de2c 100644 --- a/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf +++ b/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf @@ -776,6 +776,11 @@ The following are names of parameters or literal values and should not be transl NETSDK1174: 預留位置 {StrBegins="NETSDK1174: "} - This string is not used here, but is a placeholder for the error code, which is used by the "dotnet run" command. + + NETSDK1235: Setting the PlatformTarget property to '{0}' is not recommended for modern .NET applications. The PlatformTarget property is a legacy setting from .NET Framework and has no effect in modern .NET. Consider removing PlatformTarget or setting it to 'AnyCPU'. + NETSDK1235: Setting the PlatformTarget property to '{0}' is not recommended for modern .NET applications. The PlatformTarget property is a legacy setting from .NET Framework and has no effect in modern .NET. Consider removing PlatformTarget or setting it to 'AnyCPU'. + {StrBegins="NETSDK1235: "}{Locked="PlatformTarget"}{Locked="AnyCPU"} + NETSDK1189: Prefer32Bit is not supported and has no effect for netcoreapp target. NETSDK1189: 不支援 Prefer32Bit,且對 netcoreapp 目標沒有影響。 diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.RuntimeIdentifierInference.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.RuntimeIdentifierInference.targets index b2551a1c7251..ce15333c6180 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.RuntimeIdentifierInference.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.RuntimeIdentifierInference.targets @@ -311,6 +311,23 @@ Copyright (c) .NET Foundation. All rights reserved. + + + + + + + diff --git a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildASelfContainedApp.cs b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildASelfContainedApp.cs index fb10507bf61f..f813c3672b5e 100644 --- a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildASelfContainedApp.cs +++ b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildASelfContainedApp.cs @@ -636,5 +636,65 @@ public void It_builds_a_runnable_output_with_PreferNativeArm64(string targetFram .And .HaveStdOutContaining("Hello World!"); } + + [Theory] + [InlineData(ToolsetInfo.CurrentTargetFramework)] + public void It_warns_when_PlatformTarget_is_explicitly_set_to_non_AnyCPU(string targetFramework) + { + if (!EnvironmentInfo.SupportsTargetFramework(targetFramework)) + { + return; + } + + var testAsset = _testAssetsManager + .CopyTestAsset("HelloWorld", identifier: targetFramework) + .WithSource() + .WithTargetFramework(targetFramework) + .WithProjectChanges(project => + { + var ns = project.Root.Name.Namespace; + var propertyGroup = project.Root.Elements(ns + "PropertyGroup").First(); + propertyGroup.Add(new XElement(ns + "PlatformTarget", "x64")); + }); + + var buildCommand = new BuildCommand(testAsset); + + buildCommand + .Execute() + .Should() + .Pass() + .And + .HaveStdOutContaining("NETSDK1235"); + } + + [Theory] + [InlineData(ToolsetInfo.CurrentTargetFramework)] + public void It_does_not_warn_when_PlatformTarget_is_set_to_AnyCPU(string targetFramework) + { + if (!EnvironmentInfo.SupportsTargetFramework(targetFramework)) + { + return; + } + + var testAsset = _testAssetsManager + .CopyTestAsset("HelloWorld", identifier: targetFramework) + .WithSource() + .WithTargetFramework(targetFramework) + .WithProjectChanges(project => + { + var ns = project.Root.Name.Namespace; + var propertyGroup = project.Root.Elements(ns + "PropertyGroup").First(); + propertyGroup.Add(new XElement(ns + "PlatformTarget", "AnyCPU")); + }); + + var buildCommand = new BuildCommand(testAsset); + + buildCommand + .Execute() + .Should() + .Pass() + .And + .NotHaveStdOutContaining("NETSDK1235"); + } } }