diff --git a/src/Tasks/Common/Resources/Strings.resx b/src/Tasks/Common/Resources/Strings.resx
index 1b1faf9abff2..da29735487e6 100644
--- a/src/Tasks/Common/Resources/Strings.resx
+++ b/src/Tasks/Common/Resources/Strings.resx
@@ -875,4 +875,8 @@ You may need to build the project on another operating system or architecture, o
NETSDK1192: Targeting .NET 7.0 or higher in Visual Studio 2022 17.3 is not supported.{StrBegin="NETSDK1192: "}
+
+ NETSDK1193: In projects with TargetFrameworks >= 8.0, RuntimeIdentifier no longer automatically implies SelfContained. To preserve a project's current behavior after upgrading to 8.0, consider setting SelfContained explicitly.
+ {StrBegin="NETSDK1193: "}
+
diff --git a/src/Tasks/Common/Resources/xlf/Strings.cs.xlf b/src/Tasks/Common/Resources/xlf/Strings.cs.xlf
index 9cae172df051..d2f62f865c7e 100644
--- a/src/Tasks/Common/Resources/xlf/Strings.cs.xlf
+++ b/src/Tasks/Common/Resources/xlf/Strings.cs.xlf
@@ -770,6 +770,11 @@ The following are names of parameters or literal values and should not be transl
NETSDK1028: Zadejte parametr RuntimeIdentifier.{StrBegin="NETSDK1028: "}
+
+ NETSDK1193: In projects with TargetFrameworks >= 8.0, RuntimeIdentifier no longer automatically implies SelfContained. To preserve a project's current behavior after upgrading to 8.0, consider setting SelfContained explicitly.
+ NETSDK1193: In projects with TargetFrameworks >= 8.0, RuntimeIdentifier no longer automatically implies SelfContained. To preserve a project's current behavior after upgrading to 8.0, consider setting SelfContained explicitly.
+ {StrBegin="NETSDK1193: "}
+ NETSDK1109: Runtime list file '{0}' was not found. Report this error to the .NET team here: https://aka.ms/dotnet-sdk-issue.NETSDK1109: Soubor seznamu modulu runtime {0} nebyl nalezen. Tady můžete tuto chybu nahlásit týmu .NET: https://aka.ms/dotnet-sdk-issue.
diff --git a/src/Tasks/Common/Resources/xlf/Strings.de.xlf b/src/Tasks/Common/Resources/xlf/Strings.de.xlf
index 3c5fbc3f09fb..fe022560a2d4 100644
--- a/src/Tasks/Common/Resources/xlf/Strings.de.xlf
+++ b/src/Tasks/Common/Resources/xlf/Strings.de.xlf
@@ -770,6 +770,11 @@ The following are names of parameters or literal values and should not be transl
NETSDK1028: Geben Sie einen RuntimeIdentifier an.{StrBegin="NETSDK1028: "}
+
+ NETSDK1193: In projects with TargetFrameworks >= 8.0, RuntimeIdentifier no longer automatically implies SelfContained. To preserve a project's current behavior after upgrading to 8.0, consider setting SelfContained explicitly.
+ NETSDK1193: In projects with TargetFrameworks >= 8.0, RuntimeIdentifier no longer automatically implies SelfContained. To preserve a project's current behavior after upgrading to 8.0, consider setting SelfContained explicitly.
+ {StrBegin="NETSDK1193: "}
+ NETSDK1109: Runtime list file '{0}' was not found. Report this error to the .NET team here: https://aka.ms/dotnet-sdk-issue.NETSDK1109: Die Runtimelistendatei "{0}" wurde nicht gefunden. Melden Sie diesen Fehler hier dem .NET-Team: https://aka.ms/dotnet-sdk-issue.
diff --git a/src/Tasks/Common/Resources/xlf/Strings.es.xlf b/src/Tasks/Common/Resources/xlf/Strings.es.xlf
index 6121f4020392..86b1ea332f79 100644
--- a/src/Tasks/Common/Resources/xlf/Strings.es.xlf
+++ b/src/Tasks/Common/Resources/xlf/Strings.es.xlf
@@ -770,6 +770,11 @@ The following are names of parameters or literal values and should not be transl
NETSDK1028: Especificar un valor para RuntimeIdentifier{StrBegin="NETSDK1028: "}
+
+ NETSDK1193: In projects with TargetFrameworks >= 8.0, RuntimeIdentifier no longer automatically implies SelfContained. To preserve a project's current behavior after upgrading to 8.0, consider setting SelfContained explicitly.
+ NETSDK1193: In projects with TargetFrameworks >= 8.0, RuntimeIdentifier no longer automatically implies SelfContained. To preserve a project's current behavior after upgrading to 8.0, consider setting SelfContained explicitly.
+ {StrBegin="NETSDK1193: "}
+ NETSDK1109: Runtime list file '{0}' was not found. Report this error to the .NET team here: https://aka.ms/dotnet-sdk-issue.NETSDK1109: No se encontró el archivo de lista del entorno de ejecución "{0}". Notifique este error al equipo de .NET aquí: https://aka.ms/dotnet-sdk-issue.
diff --git a/src/Tasks/Common/Resources/xlf/Strings.fr.xlf b/src/Tasks/Common/Resources/xlf/Strings.fr.xlf
index c8011a2ef6e4..e19e624179d5 100644
--- a/src/Tasks/Common/Resources/xlf/Strings.fr.xlf
+++ b/src/Tasks/Common/Resources/xlf/Strings.fr.xlf
@@ -770,6 +770,11 @@ The following are names of parameters or literal values and should not be transl
NETSDK1028: Spécifiez un RuntimeIdentifier{StrBegin="NETSDK1028: "}
+
+ NETSDK1193: In projects with TargetFrameworks >= 8.0, RuntimeIdentifier no longer automatically implies SelfContained. To preserve a project's current behavior after upgrading to 8.0, consider setting SelfContained explicitly.
+ NETSDK1193: In projects with TargetFrameworks >= 8.0, RuntimeIdentifier no longer automatically implies SelfContained. To preserve a project's current behavior after upgrading to 8.0, consider setting SelfContained explicitly.
+ {StrBegin="NETSDK1193: "}
+ NETSDK1109: Runtime list file '{0}' was not found. Report this error to the .NET team here: https://aka.ms/dotnet-sdk-issue.NETSDK1109: Le fichier de liste de runtime '{0}' est introuvable. Signalez cette erreur à l'équipe .NET ici : https://aka.ms/dotnet-sdk-issue.
diff --git a/src/Tasks/Common/Resources/xlf/Strings.it.xlf b/src/Tasks/Common/Resources/xlf/Strings.it.xlf
index 2109529788d9..0e93e2e91767 100644
--- a/src/Tasks/Common/Resources/xlf/Strings.it.xlf
+++ b/src/Tasks/Common/Resources/xlf/Strings.it.xlf
@@ -770,6 +770,11 @@ The following are names of parameters or literal values and should not be transl
NETSDK1028: specificare un elemento RuntimeIdentifier{StrBegin="NETSDK1028: "}
+
+ NETSDK1193: In projects with TargetFrameworks >= 8.0, RuntimeIdentifier no longer automatically implies SelfContained. To preserve a project's current behavior after upgrading to 8.0, consider setting SelfContained explicitly.
+ NETSDK1193: In projects with TargetFrameworks >= 8.0, RuntimeIdentifier no longer automatically implies SelfContained. To preserve a project's current behavior after upgrading to 8.0, consider setting SelfContained explicitly.
+ {StrBegin="NETSDK1193: "}
+ NETSDK1109: Runtime list file '{0}' was not found. Report this error to the .NET team here: https://aka.ms/dotnet-sdk-issue.NETSDK1109: il file di elenco di runtime '{0}' non è stato trovato. Segnalare questo errore al team di .NET all'indirizzo: https://aka.ms/dotnet-sdk-issue.
diff --git a/src/Tasks/Common/Resources/xlf/Strings.ja.xlf b/src/Tasks/Common/Resources/xlf/Strings.ja.xlf
index 72200fa0a601..a6a16bfba363 100644
--- a/src/Tasks/Common/Resources/xlf/Strings.ja.xlf
+++ b/src/Tasks/Common/Resources/xlf/Strings.ja.xlf
@@ -770,6 +770,11 @@ The following are names of parameters or literal values and should not be transl
NETSDK1028: RuntimeIdentifier の指定{StrBegin="NETSDK1028: "}
+
+ NETSDK1193: In projects with TargetFrameworks >= 8.0, RuntimeIdentifier no longer automatically implies SelfContained. To preserve a project's current behavior after upgrading to 8.0, consider setting SelfContained explicitly.
+ NETSDK1193: In projects with TargetFrameworks >= 8.0, RuntimeIdentifier no longer automatically implies SelfContained. To preserve a project's current behavior after upgrading to 8.0, consider setting SelfContained explicitly.
+ {StrBegin="NETSDK1193: "}
+ NETSDK1109: Runtime list file '{0}' was not found. Report this error to the .NET team here: https://aka.ms/dotnet-sdk-issue.NETSDK1109: ランタイム リスト ファイル '{0}' が見つかりませんでした。https://aka.ms/dotnet-sdk-issue で、このエラーを .NET チームに報告してください。
diff --git a/src/Tasks/Common/Resources/xlf/Strings.ko.xlf b/src/Tasks/Common/Resources/xlf/Strings.ko.xlf
index ca2c91d5c3a1..7ab275b3463b 100644
--- a/src/Tasks/Common/Resources/xlf/Strings.ko.xlf
+++ b/src/Tasks/Common/Resources/xlf/Strings.ko.xlf
@@ -770,6 +770,11 @@ The following are names of parameters or literal values and should not be transl
NETSDK1028: RuntimeIdentifier 지정{StrBegin="NETSDK1028: "}
+
+ NETSDK1193: In projects with TargetFrameworks >= 8.0, RuntimeIdentifier no longer automatically implies SelfContained. To preserve a project's current behavior after upgrading to 8.0, consider setting SelfContained explicitly.
+ NETSDK1193: In projects with TargetFrameworks >= 8.0, RuntimeIdentifier no longer automatically implies SelfContained. To preserve a project's current behavior after upgrading to 8.0, consider setting SelfContained explicitly.
+ {StrBegin="NETSDK1193: "}
+ NETSDK1109: Runtime list file '{0}' was not found. Report this error to the .NET team here: https://aka.ms/dotnet-sdk-issue.NETSDK1109: 런타임 목록 파일 '{0}'을(를) 찾을 수 없습니다. https://aka.ms/dotnet-sdk-issue에서 .NET 팀에 이 오류를 보고하세요.
diff --git a/src/Tasks/Common/Resources/xlf/Strings.pl.xlf b/src/Tasks/Common/Resources/xlf/Strings.pl.xlf
index 8449f28055dc..19610c9c189d 100644
--- a/src/Tasks/Common/Resources/xlf/Strings.pl.xlf
+++ b/src/Tasks/Common/Resources/xlf/Strings.pl.xlf
@@ -770,6 +770,11 @@ The following are names of parameters or literal values and should not be transl
NETSDK1028: Określ element RuntimeIdentifier{StrBegin="NETSDK1028: "}
+
+ NETSDK1193: In projects with TargetFrameworks >= 8.0, RuntimeIdentifier no longer automatically implies SelfContained. To preserve a project's current behavior after upgrading to 8.0, consider setting SelfContained explicitly.
+ NETSDK1193: In projects with TargetFrameworks >= 8.0, RuntimeIdentifier no longer automatically implies SelfContained. To preserve a project's current behavior after upgrading to 8.0, consider setting SelfContained explicitly.
+ {StrBegin="NETSDK1193: "}
+ NETSDK1109: Runtime list file '{0}' was not found. Report this error to the .NET team here: https://aka.ms/dotnet-sdk-issue.NETSDK1109: Nie odnaleziono pliku listy środowiska uruchomieniowego „{0}”. Zgłoś ten błąd zespołowi platformy .NET tutaj: https://aka.ms/dotnet-sdk-issue.
diff --git a/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf b/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf
index 8964e711b1ff..0f4a05da01fc 100644
--- a/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf
+++ b/src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf
@@ -770,6 +770,11 @@ The following are names of parameters or literal values and should not be transl
NETSDK1028: Especifique um RuntimeIdentifier{StrBegin="NETSDK1028: "}
+
+ NETSDK1193: In projects with TargetFrameworks >= 8.0, RuntimeIdentifier no longer automatically implies SelfContained. To preserve a project's current behavior after upgrading to 8.0, consider setting SelfContained explicitly.
+ NETSDK1193: In projects with TargetFrameworks >= 8.0, RuntimeIdentifier no longer automatically implies SelfContained. To preserve a project's current behavior after upgrading to 8.0, consider setting SelfContained explicitly.
+ {StrBegin="NETSDK1193: "}
+ NETSDK1109: Runtime list file '{0}' was not found. Report this error to the .NET team here: https://aka.ms/dotnet-sdk-issue.NETSDK1109: o arquivo da lista de runtime '{0}' não foi encontrado. Relate esse erro à equipe do .NET aqui: https://aka.ms/dotnet-sdk-issue.
diff --git a/src/Tasks/Common/Resources/xlf/Strings.ru.xlf b/src/Tasks/Common/Resources/xlf/Strings.ru.xlf
index 9fb52753f7b8..dcb95e4d632d 100644
--- a/src/Tasks/Common/Resources/xlf/Strings.ru.xlf
+++ b/src/Tasks/Common/Resources/xlf/Strings.ru.xlf
@@ -770,6 +770,11 @@ The following are names of parameters or literal values and should not be transl
NETSDK1028: укажите RuntimeIdentifier{StrBegin="NETSDK1028: "}
+
+ NETSDK1193: In projects with TargetFrameworks >= 8.0, RuntimeIdentifier no longer automatically implies SelfContained. To preserve a project's current behavior after upgrading to 8.0, consider setting SelfContained explicitly.
+ NETSDK1193: In projects with TargetFrameworks >= 8.0, RuntimeIdentifier no longer automatically implies SelfContained. To preserve a project's current behavior after upgrading to 8.0, consider setting SelfContained explicitly.
+ {StrBegin="NETSDK1193: "}
+ NETSDK1109: Runtime list file '{0}' was not found. Report this error to the .NET team here: https://aka.ms/dotnet-sdk-issue.NETSDK1109: не найден файл списка среды выполнения "{0}". Сообщите об этой ошибке группе разработчиков .NET по следующему адресу: https://aka.ms/dotnet-sdk-issue.
diff --git a/src/Tasks/Common/Resources/xlf/Strings.tr.xlf b/src/Tasks/Common/Resources/xlf/Strings.tr.xlf
index 736c5276b280..358dd0761ab3 100644
--- a/src/Tasks/Common/Resources/xlf/Strings.tr.xlf
+++ b/src/Tasks/Common/Resources/xlf/Strings.tr.xlf
@@ -770,6 +770,11 @@ The following are names of parameters or literal values and should not be transl
NETSDK1028: Bir RuntimeIdentifier belirtin{StrBegin="NETSDK1028: "}
+
+ NETSDK1193: In projects with TargetFrameworks >= 8.0, RuntimeIdentifier no longer automatically implies SelfContained. To preserve a project's current behavior after upgrading to 8.0, consider setting SelfContained explicitly.
+ NETSDK1193: In projects with TargetFrameworks >= 8.0, RuntimeIdentifier no longer automatically implies SelfContained. To preserve a project's current behavior after upgrading to 8.0, consider setting SelfContained explicitly.
+ {StrBegin="NETSDK1193: "}
+ NETSDK1109: Runtime list file '{0}' was not found. Report this error to the .NET team here: https://aka.ms/dotnet-sdk-issue.NETSDK1109: '{0}' çalışma zamanı listesi dosyası bulunamadı. Bu hatayı https://aka.ms/dotnet-sdk-issue adresinden .NET ekibine bildirin.
diff --git a/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf b/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf
index b245ebe4ad9f..478418c4f0f8 100644
--- a/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf
+++ b/src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf
@@ -770,6 +770,11 @@ The following are names of parameters or literal values and should not be transl
NETSDK1028: 指定一个 RuntimeIdentifier{StrBegin="NETSDK1028: "}
+
+ NETSDK1193: In projects with TargetFrameworks >= 8.0, RuntimeIdentifier no longer automatically implies SelfContained. To preserve a project's current behavior after upgrading to 8.0, consider setting SelfContained explicitly.
+ NETSDK1193: In projects with TargetFrameworks >= 8.0, RuntimeIdentifier no longer automatically implies SelfContained. To preserve a project's current behavior after upgrading to 8.0, consider setting SelfContained explicitly.
+ {StrBegin="NETSDK1193: "}
+ NETSDK1109: Runtime list file '{0}' was not found. Report this error to the .NET team here: https://aka.ms/dotnet-sdk-issue.NETSDK1109: 找不到运行时列表文件“{0}”。请在此处将此错误报告给 .NET 团队: https://aka.ms/dotnet-sdk-issue。
diff --git a/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf b/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf
index 9568f87fd669..e187b536e372 100644
--- a/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf
+++ b/src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf
@@ -770,6 +770,11 @@ The following are names of parameters or literal values and should not be transl
NETSDK1028: 指定 RuntimeIdentifier{StrBegin="NETSDK1028: "}
+
+ NETSDK1193: In projects with TargetFrameworks >= 8.0, RuntimeIdentifier no longer automatically implies SelfContained. To preserve a project's current behavior after upgrading to 8.0, consider setting SelfContained explicitly.
+ NETSDK1193: In projects with TargetFrameworks >= 8.0, RuntimeIdentifier no longer automatically implies SelfContained. To preserve a project's current behavior after upgrading to 8.0, consider setting SelfContained explicitly.
+ {StrBegin="NETSDK1193: "}
+ NETSDK1109: Runtime list file '{0}' was not found. Report this error to the .NET team here: https://aka.ms/dotnet-sdk-issue.NETSDK1109: 找不到執行階段清單檔案 '{0}'。請將此錯誤回報給 .NET 小組: https://aka.ms/dotnet-sdk-issue。
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 84b21ee0dd82..8587e55f03ce 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
@@ -61,6 +61,14 @@ Copyright (c) .NET Foundation. All rights reserved.
win7-x86
+
+ true
+
+
+
+ $(NETCoreSdkRuntimeIdentifier)
+
+
true
- true
+ truefalse
<_RuntimeIdentifierUsesAppHost Condition="$(RuntimeIdentifier.StartsWith('ios')) or $(RuntimeIdentifier.StartsWith('tvos')) or $(RuntimeIdentifier.StartsWith('maccatalyst')) or $(RuntimeIdentifier.StartsWith('android')) or $(RuntimeIdentifier.StartsWith('browser'))">false
<_RuntimeIdentifierUsesAppHost Condition="'$(_RuntimeIdentifierUsesAppHost)' == ''">true
@@ -197,6 +205,11 @@ Copyright (c) .NET Foundation. All rights reserved.
+
+
+
@@ -222,7 +235,7 @@ Copyright (c) .NET Foundation. All rights reserved.
ResourceName="Prefer32BitIgnoredForNetCoreApp" />
- false
+ false
@@ -234,7 +247,7 @@ Copyright (c) .NET Foundation. All rights reserved.
-
+
- {
- var ns = project.Root.Name.Namespace;
- var propertyGroup = project.Root.Elements(ns + "PropertyGroup").First();
- propertyGroup.Add(new XElement(ns + "RuntimeIdentifier", RuntimeIdentifier));
+ .CopyTestAsset("HelloWorld")
+ .WithSource()
+ .WithProjectChanges(project =>
+ {
+ var ns = project.Root.Name.Namespace;
+ var propertyGroup = project.Root.Elements(ns + "PropertyGroup").First();
+ propertyGroup.Add(new XElement(ns + "RuntimeIdentifier", RuntimeIdentifier));
propertyGroup.Add(new XElement(ns + "PlatformTarget", PlatformTarget));
- });
+ });
- var buildCommand = new BuildCommand(testAsset);
+ var buildCommand = new BuildCommand(testAsset);
- buildCommand
- .Execute()
- .Should()
+ buildCommand
+ .Execute()
+ .Should()
.Fail()
.And.HaveStdOutContaining(string.Format(
Strings.CannotHaveRuntimeIdentifierPlatformMismatchPlatformTarget,
@@ -121,41 +121,41 @@ public void It_errors_out_when_RuntimeIdentifier_architecture_and_PlatformTarget
PlatformTarget));
}
- [Fact]
- public void It_succeeds_when_RuntimeIdentifier_and_PlatformTarget_mismatch_but_PT_is_AnyCPU()
- {
- var targetFramework = ToolsetInfo.CurrentTargetFramework;
- var runtimeIdentifier = EnvironmentInfo.GetCompatibleRid(targetFramework);
- var testAsset = _testAssetsManager
- .CopyTestAsset("HelloWorld")
- .WithSource()
- .WithProjectChanges(project =>
- {
- var ns = project.Root.Name.Namespace;
- var propertyGroup = project.Root.Elements(ns + "PropertyGroup").First();
- propertyGroup.Add(new XElement(ns + "RuntimeIdentifier", runtimeIdentifier));
- propertyGroup.Add(new XElement(ns + "PlatformTarget", "AnyCPU"));
- });
-
- var buildCommand = new BuildCommand(testAsset);
-
- buildCommand
- .Execute()
- .Should()
- .Pass();
-
- var outputDirectory = buildCommand.GetOutputDirectory(targetFramework, runtimeIdentifier: runtimeIdentifier);
- var selfContainedExecutable = $"HelloWorld{Constants.ExeSuffix}";
-
- string selfContainedExecutableFullPath = Path.Combine(outputDirectory.FullName, selfContainedExecutable);
+ [Fact]
+ public void It_succeeds_when_RuntimeIdentifier_and_PlatformTarget_mismatch_but_PT_is_AnyCPU()
+ {
+ var targetFramework = ToolsetInfo.CurrentTargetFramework;
+ var runtimeIdentifier = EnvironmentInfo.GetCompatibleRid(targetFramework);
+ var testAsset = _testAssetsManager
+ .CopyTestAsset("HelloWorld")
+ .WithSource()
+ .WithProjectChanges(project =>
+ {
+ var ns = project.Root.Name.Namespace;
+ var propertyGroup = project.Root.Elements(ns + "PropertyGroup").First();
+ propertyGroup.Add(new XElement(ns + "RuntimeIdentifier", runtimeIdentifier));
+ propertyGroup.Add(new XElement(ns + "PlatformTarget", "AnyCPU"));
+ });
+
+ var buildCommand = new BuildCommand(testAsset);
+
+ buildCommand
+ .Execute()
+ .Should()
+ .Pass();
+
+ var outputDirectory = buildCommand.GetOutputDirectory(targetFramework, runtimeIdentifier: runtimeIdentifier);
+ var selfContainedExecutable = $"HelloWorld{Constants.ExeSuffix}";
+
+ string selfContainedExecutableFullPath = Path.Combine(outputDirectory.FullName, selfContainedExecutable);
new RunExeCommand(Log, selfContainedExecutableFullPath)
- .Execute()
- .Should()
- .Pass()
- .And
- .HaveStdOutContaining("Hello World!");
- }
+ .Execute()
+ .Should()
+ .Pass()
+ .And
+ .HaveStdOutContaining("Hello World!");
+ }
[RequiresMSBuildVersionFact("17.0.0.32901")]
public void It_resolves_runtimepack_from_packs_folder()
@@ -317,7 +317,7 @@ static int Last2DigitsTo0(int versionBuild)
");
// Verify correct targeting pack version is resolved
- var getValuesCommand = (GetValuesCommand) new GetValuesCommand(testAsset, "TargetingPack", GetValuesCommand.ValueType.Item)
+ var getValuesCommand = (GetValuesCommand)new GetValuesCommand(testAsset, "TargetingPack", GetValuesCommand.ValueType.Item)
.WithEnvironmentVariable(EnvironmentVariableNames.WORKLOAD_MANIFEST_ROOTS, manifestRoot);
getValuesCommand.MetadataNames = new List() { "NuGetPackageId", "NuGetPackageVersion" };
getValuesCommand.DependsOnTargets = "ProcessFrameworkReferences";
@@ -351,19 +351,22 @@ static int Last2DigitsTo0(int versionBuild)
[Theory]
[InlineData("net6.0")]
- public void It_can_publish_runtime_specific_apps_with_library_dependencies_self_contained(string targetFramework) {
+ public void It_can_publish_runtime_specific_apps_with_library_dependencies_self_contained(string targetFramework)
+ {
// create a basic library and a basic app, reference the library from the app and then
// publish the app with a RID specified and self-contained.
// verify that no warnings about missing the --self-contained flag are emitted.
var rid = EnvironmentInfo.GetCompatibleRid(targetFramework);
- var libProject = new TestProject("RidSelfContainedLib"){
+ var libProject = new TestProject("RidSelfContainedLib")
+ {
IsExe = false,
TargetFrameworks = targetFramework,
IsSdkProject = true
};
var createdLibProject = _testAssetsManager.CreateTestProject(libProject);
- var appProject = new TestProject("RidSelfContainedApp") {
+ var appProject = new TestProject("RidSelfContainedApp")
+ {
IsExe = true,
TargetFrameworks = targetFramework,
IsSdkProject = true
@@ -371,7 +374,81 @@ public void It_can_publish_runtime_specific_apps_with_library_dependencies_self_
appProject.ReferencedProjects.Add(libProject);
var createdAppProject = _testAssetsManager.CreateTestProject(appProject);
var publishCommand = new PublishCommand(createdAppProject);
- publishCommand.Execute(new [] {"-property:SelfContained=true", "-property:_CommandLineDefinedSelfContained=true", $"-property:RuntimeIdentifier={rid}", "-property:_CommandLineDefinedRuntimeIdentifier=true" }).Should().Pass().And.NotHaveStdOutContaining("warning");
+ publishCommand.Execute(new[] { "-property:SelfContained=true", "-property:_CommandLineDefinedSelfContained=true", $"-property:RuntimeIdentifier={rid}", "-property:_CommandLineDefinedRuntimeIdentifier=true" }).Should().Pass().And.NotHaveStdOutContaining("warning");
+ }
+
+ [Theory]
+ [InlineData("net7.0")]
+ [InlineData("net8.0")]
+ public void It_does_or_doesnt_imply_SelfContained_based_on_RuntimeIdentifier_and_TargetFramework(string targetFramework)
+ {
+ var runtimeIdentifier = EnvironmentInfo.GetCompatibleRid(targetFramework);
+ var testAsset = _testAssetsManager
+ .CopyTestAsset("HelloWorld")
+ .WithSource()
+ .WithProjectChanges(project =>
+ {
+ var ns = project.Root.Name.Namespace;
+ var propertyGroup = project.Root.Elements(ns + "PropertyGroup").First();
+ propertyGroup.Add(new XElement(ns + "RuntimeIdentifier", runtimeIdentifier));
+ });
+
+ var buildCommand = new BuildCommand(testAsset);
+ buildCommand
+ .Execute()
+ .Should()
+ .Pass();
+
+ var outputDirectory = buildCommand.GetOutputDirectory(targetFramework, runtimeIdentifier: runtimeIdentifier);
+ var selfContainedExecutable = $"HelloWorld{Constants.ExeSuffix}";
+ string selfContainedExecutableFullPath = Path.Combine(outputDirectory.FullName, selfContainedExecutable);
+
+ if (targetFramework == "net7.0")
+ {
+ Assert.True(File.Exists(selfContainedExecutableFullPath));
+ }
+ else
+ {
+ Assert.False(File.Exists(selfContainedExecutableFullPath)); // RuntimeIdentifier no longer implies SelfContained for TFM >= 8
+ }
+ }
+
+ [Theory]
+ [InlineData("net7.0", true)]
+ [InlineData("net7.0", false)]
+ public void It_does_or_doesnt_warn_based_on_SelfContained_and_TargetFramework_breaking_RID_change(string targetFramework, bool defineSelfContained)
+ {
+ var runtimeIdentifier = EnvironmentInfo.GetCompatibleRid(targetFramework);
+ var testAsset = _testAssetsManager
+ .CopyTestAsset("HelloWorld")
+ .WithSource()
+ .WithProjectChanges(project =>
+ {
+ var ns = project.Root.Name.Namespace;
+ var propertyGroup = project.Root.Elements(ns + "PropertyGroup").First();
+ propertyGroup.Add(new XElement(ns + "RuntimeIdentifier", runtimeIdentifier));
+ propertyGroup.Add(new XElement(ns + "SelfContained", defineSelfContained ? "true" : ""));
+ });
+
+ var buildCommand = new BuildCommand(testAsset);
+ var commandResult = buildCommand.Execute();
+
+ if (targetFramework == "net7.0" && !defineSelfContained)
+ {
+ commandResult
+ .Should()
+ .Pass()
+ .And
+ .HaveStdOutContaining(Strings.RuntimeIdentifierWillNoLongerImplySelfContained);
+ }
+ else
+ {
+ commandResult
+ .Should()
+ .Pass()
+ .And
+ .NotHaveStdOutContaining(Strings.RuntimeIdentifierWillNoLongerImplySelfContained);
+ }
}
[Theory]
diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToUseVB.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToUseVB.cs
index 4cd4aec6d75c..768c68c764bf 100644
--- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToUseVB.cs
+++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToUseVB.cs
@@ -143,8 +143,8 @@ private static (VBRuntime, string[]) GetExpectedOutputs(string targetFramework,
});
case ("netcoreapp3.0", false):
- return (VBRuntime.Referenced, new[]
- {
+ return (VBRuntime.Referenced, new[]
+ {
"HelloWorld.dll",
"HelloWorld.pdb",
"HelloWorld.deps.json",
diff --git a/src/Tests/Microsoft.NET.Publish.Tests/RuntimeIdentifiersTests.cs b/src/Tests/Microsoft.NET.Publish.Tests/RuntimeIdentifiersTests.cs
index facaa4ac7ce5..af77243565a1 100644
--- a/src/Tests/Microsoft.NET.Publish.Tests/RuntimeIdentifiersTests.cs
+++ b/src/Tests/Microsoft.NET.Publish.Tests/RuntimeIdentifiersTests.cs
@@ -3,9 +3,11 @@
using System;
using System.Collections.Generic;
+using System.Formats.Asn1;
using System.IO;
using System.Linq;
using System.Text;
+using System.Xml.Linq;
using FluentAssertions;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.NET.TestFramework;
@@ -14,13 +16,24 @@
using Microsoft.NET.TestFramework.ProjectConstruction;
using Xunit;
using Xunit.Abstractions;
+using Xunit.Sdk;
namespace Microsoft.NET.Publish.Tests
{
public class RuntimeIdentifiersTests : SdkTest
{
+
+ TestProject _testProject;
+
public RuntimeIdentifiersTests(ITestOutputHelper log) : base(log)
{
+ _testProject = new TestProject("TestProject")
+ {
+ TargetFrameworks = ToolsetInfo.CurrentTargetFramework,
+ IsExe = true
+ };
+
+ _testProject.RecordProperties("RuntimeIdentifier", "SelfContained", "RuntimeIdentifiers");
}
// Run on core MSBuild only as using a local packages folder hits long path issues on full MSBuild
@@ -218,5 +231,63 @@ public void DuplicateRuntimeIdentifiers()
.Pass();
}
+
+ [Theory]
+ [InlineData("net7.0", "true")]
+ [InlineData("net7.0", "")]
+ public void RuntimeSpecificEnablesOrDisablesRuntimeIdentifierByDefaultBasedOnValueAndTargetFramework(string targetFramework, string runtimeSpecific)
+ {
+ TestAsset testAsset = _testAssetsManager.CreateTestProject(_testProject, identifier: $"{targetFramework}_{runtimeSpecific}")
+ .WithTargetFramework(targetFramework)
+ .WithProjectChanges(project =>
+ {
+ var ns = project.Root.Name.Namespace;
+ var propertyGroup = project.Root.Elements(ns + "PropertyGroup").First();
+ propertyGroup.Add(new XElement(ns + "RuntimeSpecific", runtimeSpecific));
+ });
+
+ var expectedRuntimeIdentifier = EnvironmentInfo.GetCompatibleRid(targetFramework);
+ new DotnetBuildCommand(testAsset)
+ .Execute($"/p:NETCoreSdkRuntimeIdentifier={expectedRuntimeIdentifier}")
+ .Should()
+ .Pass();
+
+ if ((runtimeSpecific != "false" && targetFramework == "net8.0") || runtimeSpecific == "true" && targetFramework == "net7.0")
+ {
+ var properties = _testProject.GetPropertyValues(testAsset.TestRoot, targetFramework: targetFramework, runtimeIdentifier: expectedRuntimeIdentifier);
+ var resolvedRid = properties["RuntimeIdentifier"];
+ Assert.True(resolvedRid == expectedRuntimeIdentifier);
+ }
+ else
+ {
+ var properties = _testProject.GetPropertyValues(testAsset.TestRoot, targetFramework: targetFramework);
+ var resolvedRid = properties["RuntimeIdentifier"];
+ Assert.True(resolvedRid == "");
+ }
+ }
+
+ [Theory]
+ [InlineData("net7.0")]
+ public void RuntimeIdentifiersDisablesRuntimeSpecificFDDBehavior(string targetFramework)
+ {
+ var expectedRuntimeIdentifier = EnvironmentInfo.GetCompatibleRid(targetFramework);
+ TestAsset testAsset = _testAssetsManager.CreateTestProject(_testProject, identifier: $"RuntimeIdentifierS_{targetFramework}") // the S is intentional to call atention to it
+ .WithTargetFramework(targetFramework)
+ .WithProjectChanges(project =>
+ {
+ var ns = project.Root.Name.Namespace;
+ var propertyGroup = project.Root.Elements(ns + "PropertyGroup").First();
+ propertyGroup.Add(new XElement(ns + "RuntimeIdentifiers", $"{expectedRuntimeIdentifier};{expectedRuntimeIdentifier}"));
+ });
+
+ new DotnetBuildCommand(testAsset)
+ .Execute($"/p:NETCoreSdkRuntimeIdentifier={expectedRuntimeIdentifier}")
+ .Should()
+ .Pass();
+
+ var properties = _testProject.GetPropertyValues(testAsset.TestRoot, targetFramework: targetFramework, runtimeIdentifier: expectedRuntimeIdentifier);
+ var resolvedRid = properties["RuntimeIdentifier"];
+ Assert.True(resolvedRid == "");
+ }
}
}