Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the Implicit SDK RID for RID-Specific Apps by Default #26143

Merged
merged 12 commits into from
Sep 13, 2022
7 changes: 0 additions & 7 deletions src/Cli/dotnet/CommonOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,6 @@ public static string GetCurrentRuntimeId()
private static IEnumerable<string> ForwardSelfContainedOptions(bool isSelfContained, ParseResult parseResult)
{
IEnumerable<string> selfContainedProperties = new string[] { $"-property:SelfContained={isSelfContained}", "-property:_CommandLineDefinedSelfContained=true" };

if (!UserSpecifiedRidOption(parseResult) && isSelfContained)
{
var ridProperties = RuntimeArgFunc(GetCurrentRuntimeId());
selfContainedProperties = selfContainedProperties.Concat(ridProperties);
}

return selfContainedProperties;
}

Expand Down
6 changes: 5 additions & 1 deletion src/Tasks/Common/Resources/Strings.resx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Expand Down Expand Up @@ -867,4 +867,8 @@ You may need to build the project on another operating system or architecture, o
<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>
<comment>{StrBegin="NETSDK1190: "}</comment>
</data>
<data name="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed" xml:space="preserve">
<value>NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</value>
<comment>{StrBegin="NETSDK1191: "}</comment>
</data>
</root>
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,11 @@
<target state="translated">Optimalizace velikosti sestavení Tento proces může chvíli trvat.</target>
<note />
</trans-unit>
<trans-unit id="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed">
<source>NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</source>
<target state="new">NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</target>
<note>{StrBegin="NETSDK1191: "}</note>
</trans-unit>
<trans-unit id="IncorrectPackageRoot">
<source>NETSDK1020: Package Root {0} was incorrectly given for Resolved library {1}</source>
<target state="translated">NETSDK1020: Kořen balíčku {0} byl pro rozpoznanou knihovnu {1} nesprávně zadán.</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,11 @@
<target state="translated">Assemblys werden für die Größe optimiert. Dieser Vorgang kann eine Weile dauern.</target>
<note />
</trans-unit>
<trans-unit id="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed">
<source>NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</source>
<target state="new">NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</target>
<note>{StrBegin="NETSDK1191: "}</note>
</trans-unit>
<trans-unit id="IncorrectPackageRoot">
<source>NETSDK1020: Package Root {0} was incorrectly given for Resolved library {1}</source>
<target state="translated">NETSDK1020: Der Paketstamm "{0}" war für die aufgelöste Bibliothek "{1}" falsch angegeben.</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,11 @@
<target state="translated">Optimización del tamaño de los ensamblados. Este proceso puede tardar un momento.</target>
<note />
</trans-unit>
<trans-unit id="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed">
<source>NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</source>
<target state="new">NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</target>
<note>{StrBegin="NETSDK1191: "}</note>
</trans-unit>
<trans-unit id="IncorrectPackageRoot">
<source>NETSDK1020: Package Root {0} was incorrectly given for Resolved library {1}</source>
<target state="translated">NETSDK1020: Se proporcionó incorrectamente la raíz del paquete {0} para la biblioteca resuelta {1}</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,11 @@
<target state="translated">Optimisation des assemblages pour la taille. Ce processus peut prendre un certain temps.</target>
<note />
</trans-unit>
<trans-unit id="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed">
<source>NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</source>
<target state="new">NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</target>
<note>{StrBegin="NETSDK1191: "}</note>
</trans-unit>
<trans-unit id="IncorrectPackageRoot">
<source>NETSDK1020: Package Root {0} was incorrectly given for Resolved library {1}</source>
<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>
Expand Down
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.it.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,11 @@
<target state="translated">Ottimizzazione degli assembly per le dimensioni. Questo processo potrebbe richiedere del tempo.</target>
<note />
</trans-unit>
<trans-unit id="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed">
<source>NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</source>
<target state="new">NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</target>
<note>{StrBegin="NETSDK1191: "}</note>
</trans-unit>
<trans-unit id="IncorrectPackageRoot">
<source>NETSDK1020: Package Root {0} was incorrectly given for Resolved library {1}</source>
<target state="translated">NETSDK1020: la radice {0} del pacchetto specificata per la libreria risolta {1} non è corretta</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.ja.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,11 @@
<target state="translated">アセンブリのサイズを最適化しています。このプロセスには時間がかかる場合があります。</target>
<note />
</trans-unit>
<trans-unit id="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed">
<source>NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</source>
<target state="new">NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</target>
<note>{StrBegin="NETSDK1191: "}</note>
</trans-unit>
<trans-unit id="IncorrectPackageRoot">
<source>NETSDK1020: Package Root {0} was incorrectly given for Resolved library {1}</source>
<target state="translated">NETSDK1020: 解決されたライブラリ {1} に対して指定されたパッケージ ルート {0} が正しくありません。</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.ko.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,11 @@
<target state="translated">크기에 맞게 어셈블리 최적화. 이 프로세스는 시간이 걸릴 수 있습니다.</target>
<note />
</trans-unit>
<trans-unit id="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed">
<source>NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</source>
<target state="new">NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</target>
<note>{StrBegin="NETSDK1191: "}</note>
</trans-unit>
<trans-unit id="IncorrectPackageRoot">
<source>NETSDK1020: Package Root {0} was incorrectly given for Resolved library {1}</source>
<target state="translated">NETSDK1020: 패키지 루트 {0}이(가) 확인된 라이브러리 {1}에 대해 잘못 지정되었습니다.</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.pl.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,11 @@
<target state="translated">Optymalizowanie zestawów pod kątem rozmiaru. Ten proces może trochę potrwać.</target>
<note />
</trans-unit>
<trans-unit id="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed">
<source>NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</source>
<target state="new">NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</target>
<note>{StrBegin="NETSDK1191: "}</note>
</trans-unit>
<trans-unit id="IncorrectPackageRoot">
<source>NETSDK1020: Package Root {0} was incorrectly given for Resolved library {1}</source>
<target state="translated">NETSDK1020: Podano niepoprawny element główny pakietu {0} dla rozpoznanej biblioteki {1}</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,11 @@
<target state="translated">Otimizando montagens para tamanho. Esse processo pode demorar um pouco.</target>
<note />
</trans-unit>
<trans-unit id="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed">
<source>NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</source>
<target state="new">NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</target>
<note>{StrBegin="NETSDK1191: "}</note>
</trans-unit>
<trans-unit id="IncorrectPackageRoot">
<source>NETSDK1020: Package Root {0} was incorrectly given for Resolved library {1}</source>
<target state="translated">NETSDK1020: A raiz do pacote {0} foi atribuída incorretamente para a biblioteca resolvida {1}</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.ru.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,11 @@
<target state="translated">Оптимизация сборок по размеру. Этот процесс может занять некоторое время.</target>
<note />
</trans-unit>
<trans-unit id="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed">
<source>NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</source>
<target state="new">NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</target>
<note>{StrBegin="NETSDK1191: "}</note>
</trans-unit>
<trans-unit id="IncorrectPackageRoot">
<source>NETSDK1020: Package Root {0} was incorrectly given for Resolved library {1}</source>
<target state="translated">NETSDK1020: корневой каталог пакета {0} указан некорректно для разрешенной библиотеки {1}</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.tr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,11 @@
<target state="translated">Derlemelerin boyutu iyileştiriliyor. Bu işlem biraz zaman alabilir.</target>
<note />
</trans-unit>
<trans-unit id="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed">
<source>NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</source>
<target state="new">NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</target>
<note>{StrBegin="NETSDK1191: "}</note>
</trans-unit>
<trans-unit id="IncorrectPackageRoot">
<source>NETSDK1020: Package Root {0} was incorrectly given for Resolved library {1}</source>
<target state="translated">NETSDK1020: {0} Paket Kökü, Çözümlenmiş {1} kitaplığı için yanlışlıkla verildi</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,11 @@
<target state="translated">正在优化程序集以调整大小。此过程可能需要一段时间。</target>
<note />
</trans-unit>
<trans-unit id="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed">
<source>NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</source>
<target state="new">NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</target>
<note>{StrBegin="NETSDK1191: "}</note>
</trans-unit>
<trans-unit id="IncorrectPackageRoot">
<source>NETSDK1020: Package Root {0} was incorrectly given for Resolved library {1}</source>
<target state="translated">NETSDK1020: 对于“已解析”库 {1},包根目录 {0} 分配错误</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,11 @@
<target state="translated">正在針對大小最佳化組件。此流程可能需要一些時間。</target>
<note />
</trans-unit>
<trans-unit id="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed">
<source>NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</source>
<target state="new">NETSDK1191: A runtime identifier for the property '{0}' couldn't be inferred. Specify a rid explicitly.</target>
<note>{StrBegin="NETSDK1191: "}</note>
</trans-unit>
<trans-unit id="IncorrectPackageRoot">
<source>NETSDK1020: Package Root {0} was incorrectly given for Resolved library {1}</source>
<target state="translated">NETSDK1020: 為已解析的程式庫 {1} 指定的套件根 {0} 不正確</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,17 @@ Copyright (c) .NET Foundation. All rights reserved.
<RuntimeIdentifier Condition="'$(PlatformTarget)' == 'x86' or '$(PlatformTarget)' == ''">win7-x86</RuntimeIdentifier>
</PropertyGroup>

<PropertyGroup Condition="'$(UseCurrentRuntimeIdentifier)' == 'true'">
<PropertyGroup Condition="'$(UseCurrentRuntimeIdentifier)' == 'true' or
(
'$(RuntimeIdentifier)' == '' and
'$(RuntimeIdentifiers)' == '' and
(
'$(SelfContained)' == 'true' or
'$(PublishReadyToRun)' == 'true' or
'$(PublishSingleFile)' == 'true' or
'$(PublishAot)' == 'true'
)
)">
<RuntimeIdentifier>$(NETCoreSdkPortableRuntimeIdentifier)</RuntimeIdentifier>
</PropertyGroup>

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

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

<NETSdkError Condition="'$(PublishReadyToRun)' == 'true' and '$(RuntimeIdentifier)' == ''"
ResourceName="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed"
FormatArguments="PublishReadyToRun"/>

<NETSdkError Condition="'$(PublishSingleFile)' == 'true' and '$(RuntimeIdentifier)' == ''"
ResourceName="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed"
FormatArguments="PublishSingleFile"/>

<NETSdkError Condition="'$(PublishAot)' == 'true' and '$(RuntimeIdentifier)' == ''"
ResourceName="ImplicitRuntimeIdentifierResolutionForPublishPropertyFailed"
FormatArguments="PublishAot"/>

<!-- End of implicit RID resolver checks.-->
<NETSdkError Condition="'$(SelfContained)' == 'true' and '$(UseAppHost)' != 'true' and '$(_RuntimeIdentifierUsesAppHost)' == 'true'"
ResourceName="CannotUseSelfContainedWithoutAppHost" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public GlobalPropertyFlowTests(ITestOutputHelper log) : base(log)

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

var arguments = GetDotnetArguments(passSelfContained, passRuntimeIdentifier);

Expand Down Expand Up @@ -228,7 +228,7 @@ public void TestGlobalPropertyFlowInSolution(bool passSelfContained, bool passRu

var arguments = GetDotnetArguments(passSelfContained, passRuntimeIdentifier);

if (passSelfContained || passRuntimeIdentifier)
if (passRuntimeIdentifier)
{
new DotnetBuildCommand(Log, arguments.ToArray())
.WithWorkingDirectory(testAsset.TestRoot)
Expand All @@ -252,7 +252,7 @@ private static void ValidateProperties(TestAsset testAsset, TestProject testProj
{
targetFramework = targetFramework ?? testProject.TargetFrameworks;


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

properties["RuntimeIdentifier"].Should().Be(expectedRuntimeIdentifier);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,29 @@ public void It_publishes_with_full_path_publish_profile()
.Pass();
}

[Theory]
[InlineData("--p:PublishReadyToRun=true")]
[InlineData("-p:PublishSingleFile=true")]
[InlineData("")]
public void It_publishes_with_implicit_rid_with_rid_specific_properties(string executeOptionsAndProperties)
{
var testProject = new TestProject()
{
Name = "PublishImplicitRid",
TargetFrameworks = $"net472;{ToolsetInfo.CurrentTargetFramework}",
};
testProject.AdditionalProperties.Add("IsPublishable", "false");
var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: executeOptionsAndProperties);

var publishCommand = new PublishCommand(testAsset);
publishCommand
.Execute(executeOptionsAndProperties)
.Should()
.Pass()
.And
.NotHaveStdErrContaining("NETSDK1191"); // Publish Properties Requiring RID Checks
}

[Fact]
public void IsPublishableIsRespectedWhenMultitargeting()
{
Expand Down
Loading