Skip to content

Commit 281a049

Browse files
authored
Merge pull request #26143 from nagilson/nagilson-implicit-rid
Use the Implicit SDK RID for RID-Specific Apps by Default
2 parents aedd50d + 4e81ebb commit 281a049

24 files changed

+186
-74
lines changed

src/Cli/dotnet/CommonOptions.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -261,13 +261,6 @@ public static string GetCurrentRuntimeId()
261261
private static IEnumerable<string> ForwardSelfContainedOptions(bool isSelfContained, ParseResult parseResult)
262262
{
263263
IEnumerable<string> selfContainedProperties = new string[] { $"-property:SelfContained={isSelfContained}", "-property:_CommandLineDefinedSelfContained=true" };
264-
265-
if (!UserSpecifiedRidOption(parseResult) && isSelfContained)
266-
{
267-
var ridProperties = RuntimeArgFunc(GetCurrentRuntimeId());
268-
selfContainedProperties = selfContainedProperties.Concat(ridProperties);
269-
}
270-
271264
return selfContainedProperties;
272265
}
273266

src/Tasks/Common/Resources/Strings.resx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<root>
33
<!--
44
Microsoft ResX Schema
@@ -867,4 +867,8 @@ You may need to build the project on another operating system or architecture, o
867867
<value>NETSDK1190: To use '{0}' in solution projects, you must set the environment variable '{1}' (to true). This will increase the time to complete the operation.</value>
868868
<comment>{StrBegin="NETSDK1190: "}</comment>
869869
</data>
870+
<data name="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed" xml:space="preserve">
871+
<value>NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</value>
872+
<comment>{StrBegin="NETSDK1191: "}</comment>
873+
</data>
870874
</root>

src/Tasks/Common/Resources/xlf/Strings.cs.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,11 @@
464464
<target state="translated">Optimalizace velikosti sestavení Tento proces může chvíli trvat.</target>
465465
<note />
466466
</trans-unit>
467+
<trans-unit id="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed">
468+
<source>NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</source>
469+
<target state="new">NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</target>
470+
<note>{StrBegin="NETSDK1191: "}</note>
471+
</trans-unit>
467472
<trans-unit id="IncorrectPackageRoot">
468473
<source>NETSDK1020: Package Root {0} was incorrectly given for Resolved library {1}</source>
469474
<target state="translated">NETSDK1020: Kořen balíčku {0} byl pro rozpoznanou knihovnu {1} nesprávně zadán.</target>

src/Tasks/Common/Resources/xlf/Strings.de.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,11 @@
464464
<target state="translated">Assemblys werden für die Größe optimiert. Dieser Vorgang kann eine Weile dauern.</target>
465465
<note />
466466
</trans-unit>
467+
<trans-unit id="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed">
468+
<source>NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</source>
469+
<target state="new">NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</target>
470+
<note>{StrBegin="NETSDK1191: "}</note>
471+
</trans-unit>
467472
<trans-unit id="IncorrectPackageRoot">
468473
<source>NETSDK1020: Package Root {0} was incorrectly given for Resolved library {1}</source>
469474
<target state="translated">NETSDK1020: Der Paketstamm "{0}" war für die aufgelöste Bibliothek "{1}" falsch angegeben.</target>

src/Tasks/Common/Resources/xlf/Strings.es.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,11 @@
464464
<target state="translated">Optimización del tamaño de los ensamblados. Este proceso puede tardar un momento.</target>
465465
<note />
466466
</trans-unit>
467+
<trans-unit id="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed">
468+
<source>NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</source>
469+
<target state="new">NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</target>
470+
<note>{StrBegin="NETSDK1191: "}</note>
471+
</trans-unit>
467472
<trans-unit id="IncorrectPackageRoot">
468473
<source>NETSDK1020: Package Root {0} was incorrectly given for Resolved library {1}</source>
469474
<target state="translated">NETSDK1020: Se proporcionó incorrectamente la raíz del paquete {0} para la biblioteca resuelta {1}</target>

src/Tasks/Common/Resources/xlf/Strings.fr.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,11 @@
464464
<target state="translated">Optimisation des assemblages pour la taille. Ce processus peut prendre un certain temps.</target>
465465
<note />
466466
</trans-unit>
467+
<trans-unit id="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed">
468+
<source>NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</source>
469+
<target state="new">NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</target>
470+
<note>{StrBegin="NETSDK1191: "}</note>
471+
</trans-unit>
467472
<trans-unit id="IncorrectPackageRoot">
468473
<source>NETSDK1020: Package Root {0} was incorrectly given for Resolved library {1}</source>
469474
<target state="translated">NETSDK1020: La racine de package {0} a été spécifiée de manière incorrecte pour la bibliothèque Resolved {1}</target>

src/Tasks/Common/Resources/xlf/Strings.it.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,11 @@
464464
<target state="translated">Ottimizzazione degli assembly per le dimensioni. Questo processo potrebbe richiedere del tempo.</target>
465465
<note />
466466
</trans-unit>
467+
<trans-unit id="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed">
468+
<source>NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</source>
469+
<target state="new">NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</target>
470+
<note>{StrBegin="NETSDK1191: "}</note>
471+
</trans-unit>
467472
<trans-unit id="IncorrectPackageRoot">
468473
<source>NETSDK1020: Package Root {0} was incorrectly given for Resolved library {1}</source>
469474
<target state="translated">NETSDK1020: la radice {0} del pacchetto specificata per la libreria risolta {1} non è corretta</target>

src/Tasks/Common/Resources/xlf/Strings.ja.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,11 @@
464464
<target state="translated">アセンブリのサイズを最適化しています。このプロセスには時間がかかる場合があります。</target>
465465
<note />
466466
</trans-unit>
467+
<trans-unit id="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed">
468+
<source>NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</source>
469+
<target state="new">NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</target>
470+
<note>{StrBegin="NETSDK1191: "}</note>
471+
</trans-unit>
467472
<trans-unit id="IncorrectPackageRoot">
468473
<source>NETSDK1020: Package Root {0} was incorrectly given for Resolved library {1}</source>
469474
<target state="translated">NETSDK1020: 解決されたライブラリ {1} に対して指定されたパッケージ ルート {0} が正しくありません。</target>

src/Tasks/Common/Resources/xlf/Strings.ko.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,11 @@
464464
<target state="translated">크기에 맞게 어셈블리 최적화. 이 프로세스는 시간이 걸릴 수 있습니다.</target>
465465
<note />
466466
</trans-unit>
467+
<trans-unit id="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed">
468+
<source>NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</source>
469+
<target state="new">NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</target>
470+
<note>{StrBegin="NETSDK1191: "}</note>
471+
</trans-unit>
467472
<trans-unit id="IncorrectPackageRoot">
468473
<source>NETSDK1020: Package Root {0} was incorrectly given for Resolved library {1}</source>
469474
<target state="translated">NETSDK1020: 패키지 루트 {0}이(가) 확인된 라이브러리 {1}에 대해 잘못 지정되었습니다.</target>

src/Tasks/Common/Resources/xlf/Strings.pl.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,11 @@
464464
<target state="translated">Optymalizowanie zestawów pod kątem rozmiaru. Ten proces może trochę potrwać.</target>
465465
<note />
466466
</trans-unit>
467+
<trans-unit id="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed">
468+
<source>NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</source>
469+
<target state="new">NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</target>
470+
<note>{StrBegin="NETSDK1191: "}</note>
471+
</trans-unit>
467472
<trans-unit id="IncorrectPackageRoot">
468473
<source>NETSDK1020: Package Root {0} was incorrectly given for Resolved library {1}</source>
469474
<target state="translated">NETSDK1020: Podano niepoprawny element główny pakietu {0} dla rozpoznanej biblioteki {1}</target>

src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,11 @@
464464
<target state="translated">Otimizando montagens para tamanho. Esse processo pode demorar um pouco.</target>
465465
<note />
466466
</trans-unit>
467+
<trans-unit id="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed">
468+
<source>NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</source>
469+
<target state="new">NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</target>
470+
<note>{StrBegin="NETSDK1191: "}</note>
471+
</trans-unit>
467472
<trans-unit id="IncorrectPackageRoot">
468473
<source>NETSDK1020: Package Root {0} was incorrectly given for Resolved library {1}</source>
469474
<target state="translated">NETSDK1020: A raiz do pacote {0} foi atribuída incorretamente para a biblioteca resolvida {1}</target>

src/Tasks/Common/Resources/xlf/Strings.ru.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,11 @@
464464
<target state="translated">Оптимизация сборок по размеру. Этот процесс может занять некоторое время.</target>
465465
<note />
466466
</trans-unit>
467+
<trans-unit id="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed">
468+
<source>NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</source>
469+
<target state="new">NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</target>
470+
<note>{StrBegin="NETSDK1191: "}</note>
471+
</trans-unit>
467472
<trans-unit id="IncorrectPackageRoot">
468473
<source>NETSDK1020: Package Root {0} was incorrectly given for Resolved library {1}</source>
469474
<target state="translated">NETSDK1020: корневой каталог пакета {0} указан некорректно для разрешенной библиотеки {1}</target>

src/Tasks/Common/Resources/xlf/Strings.tr.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,11 @@
464464
<target state="translated">Derlemelerin boyutu iyileştiriliyor. Bu işlem biraz zaman alabilir.</target>
465465
<note />
466466
</trans-unit>
467+
<trans-unit id="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed">
468+
<source>NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</source>
469+
<target state="new">NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</target>
470+
<note>{StrBegin="NETSDK1191: "}</note>
471+
</trans-unit>
467472
<trans-unit id="IncorrectPackageRoot">
468473
<source>NETSDK1020: Package Root {0} was incorrectly given for Resolved library {1}</source>
469474
<target state="translated">NETSDK1020: {0} Paket Kökü, Çözümlenmiş {1} kitaplığı için yanlışlıkla verildi</target>

src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,11 @@
464464
<target state="translated">正在优化程序集以调整大小。此过程可能需要一段时间。</target>
465465
<note />
466466
</trans-unit>
467+
<trans-unit id="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed">
468+
<source>NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</source>
469+
<target state="new">NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</target>
470+
<note>{StrBegin="NETSDK1191: "}</note>
471+
</trans-unit>
467472
<trans-unit id="IncorrectPackageRoot">
468473
<source>NETSDK1020: Package Root {0} was incorrectly given for Resolved library {1}</source>
469474
<target state="translated">NETSDK1020: 对于“已解析”库 {1},包根目录 {0} 分配错误</target>

src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,11 @@
464464
<target state="translated">正在針對大小最佳化組件。此流程可能需要一些時間。</target>
465465
<note />
466466
</trans-unit>
467+
<trans-unit id="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed">
468+
<source>NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</source>
469+
<target state="new">NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</target>
470+
<note>{StrBegin="NETSDK1191: "}</note>
471+
</trans-unit>
467472
<trans-unit id="IncorrectPackageRoot">
468473
<source>NETSDK1020: Package Root {0} was incorrectly given for Resolved library {1}</source>
469474
<target state="translated">NETSDK1020: 為已解析的程式庫 {1} 指定的套件根 {0} 不正確</target>

src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.RuntimeIdentifierInference.targets

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,17 @@ Copyright (c) .NET Foundation. All rights reserved.
6161
<RuntimeIdentifier Condition="'$(PlatformTarget)' == 'x86' or '$(PlatformTarget)' == ''">win7-x86</RuntimeIdentifier>
6262
</PropertyGroup>
6363

64-
<PropertyGroup Condition="'$(UseCurrentRuntimeIdentifier)' == 'true'">
64+
<PropertyGroup Condition="'$(UseCurrentRuntimeIdentifier)' == 'true' or
65+
(
66+
'$(RuntimeIdentifier)' == '' and
67+
'$(RuntimeIdentifiers)' == '' and
68+
(
69+
'$(SelfContained)' == 'true' or
70+
'$(PublishReadyToRun)' == 'true' or
71+
'$(PublishSingleFile)' == 'true' or
72+
'$(PublishAot)' == 'true'
73+
)
74+
)">
6575
<RuntimeIdentifier>$(NETCoreSdkPortableRuntimeIdentifier)</RuntimeIdentifier>
6676
</PropertyGroup>
6777

@@ -151,9 +161,24 @@ Copyright (c) .NET Foundation. All rights reserved.
151161
BeforeTargets="_CheckForInvalidConfigurationAndPlatform"
152162
Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and '$(HasRuntimeOutput)' == 'true'">
153163

164+
<!-- The following RID errors are asserts, and we don't expect them to ever occur. The error message is added as a safeguard.-->
154165
<NETSdkError Condition="'$(SelfContained)' == 'true' and '$(RuntimeIdentifier)' == ''"
155-
ResourceName="CannotHaveSelfContainedWithoutRuntimeIdentifier" />
166+
ResourceName="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed"
167+
FormatArguments="SelfContained"/>
156168

169+
<NETSdkError Condition="'$(PublishReadyToRun)' == 'true' and '$(RuntimeIdentifier)' == ''"
170+
ResourceName="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed"
171+
FormatArguments="PublishReadyToRun"/>
172+
173+
<NETSdkError Condition="'$(PublishSingleFile)' == 'true' and '$(RuntimeIdentifier)' == ''"
174+
ResourceName="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed"
175+
FormatArguments="PublishSingleFile"/>
176+
177+
<NETSdkError Condition="'$(PublishAot)' == 'true' and '$(RuntimeIdentifier)' == ''"
178+
ResourceName="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed"
179+
FormatArguments="PublishAot"/>
180+
181+
<!-- End of implicit RID resolver checks.-->
157182
<NETSdkError Condition="'$(SelfContained)' == 'true' and '$(UseAppHost)' != 'true' and '$(_RuntimeIdentifierUsesAppHost)' == 'true'"
158183
ResourceName="CannotUseSelfContainedWithoutAppHost" />
159184

src/Tests/Microsoft.NET.Build.Tests/GlobalPropertyFlowTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public GlobalPropertyFlowTests(ITestOutputHelper log) : base(log)
4545

4646
TestAsset Build(bool passSelfContained, bool passRuntimeIdentifier, [CallerMemberName] string callingMethod = "", string identifier = "")
4747
{
48-
var testAsset = _testAssetsManager.CreateTestProject(_testProject, callingMethod: callingMethod, identifier:identifier);
48+
var testAsset = _testAssetsManager.CreateTestProject(_testProject, callingMethod: callingMethod, identifier: identifier);
4949

5050
var arguments = GetDotnetArguments(passSelfContained, passRuntimeIdentifier);
5151

@@ -228,7 +228,7 @@ public void TestGlobalPropertyFlowInSolution(bool passSelfContained, bool passRu
228228

229229
var arguments = GetDotnetArguments(passSelfContained, passRuntimeIdentifier);
230230

231-
if (passSelfContained || passRuntimeIdentifier)
231+
if (passRuntimeIdentifier)
232232
{
233233
new DotnetBuildCommand(Log, arguments.ToArray())
234234
.WithWorkingDirectory(testAsset.TestRoot)
@@ -252,7 +252,7 @@ private static void ValidateProperties(TestAsset testAsset, TestProject testProj
252252
{
253253
targetFramework = targetFramework ?? testProject.TargetFrameworks;
254254

255-
255+
256256
if (string.IsNullOrEmpty(expectedRuntimeIdentifier) && (expectSelfContained || expectRuntimeIdentifier))
257257
{
258258
// RuntimeIdentifier might be inferred, so look at the output path to figure out what the actual value used was
@@ -269,7 +269,7 @@ private static void ValidateProperties(TestAsset testAsset, TestProject testProj
269269
{
270270
properties["SelfContained"].ToLowerInvariant().Should().BeOneOf("false", "");
271271
}
272-
272+
273273
properties["RuntimeIdentifier"].Should().Be(expectedRuntimeIdentifier);
274274
}
275275

src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAHelloWorldProject.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,6 +1051,29 @@ public void It_publishes_with_full_path_publish_profile()
10511051
.Pass();
10521052
}
10531053

1054+
[Theory]
1055+
[InlineData("--p:PublishReadyToRun=true")]
1056+
[InlineData("-p:PublishSingleFile=true")]
1057+
[InlineData("")]
1058+
public void It_publishes_with_implicit_rid_with_rid_specific_properties(string executeOptionsAndProperties)
1059+
{
1060+
var testProject = new TestProject()
1061+
{
1062+
Name = "PublishImplicitRid",
1063+
TargetFrameworks = $"net472;{ToolsetInfo.CurrentTargetFramework}",
1064+
};
1065+
testProject.AdditionalProperties.Add("IsPublishable", "false");
1066+
var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: executeOptionsAndProperties);
1067+
1068+
var publishCommand = new PublishCommand(testAsset);
1069+
publishCommand
1070+
.Execute(executeOptionsAndProperties)
1071+
.Should()
1072+
.Pass()
1073+
.And
1074+
.NotHaveStdErrContaining("NETSDK1191"); // Publish Properties Requiring RID Checks
1075+
}
1076+
10541077
[Fact]
10551078
public void IsPublishableIsRespectedWhenMultitargeting()
10561079
{

0 commit comments

Comments
 (0)