From 8754ecbbf17de6b1aa34ada6bc1bc3d82c10658d Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 2 Jan 2025 12:19:02 -0800 Subject: [PATCH 1/4] Infer the projects runtime identifier as the vertical's RID when doing a vertical build and filter down RID lists to the target RID in such a scenario. --- .../tools/BeforeNETSdkTargets.targets | 4 ++ ...ifierInference.BeforeNETSdkTargets.targets | 49 +++++++++++++++++++ .../tools/Settings.props | 1 + 3 files changed, 54 insertions(+) create mode 100644 src/Microsoft.DotNet.Arcade.Sdk/tools/BeforeNETSdkTargets.targets create mode 100644 src/Microsoft.DotNet.Arcade.Sdk/tools/RuntimeIdentifierInference.BeforeNETSdkTargets.targets diff --git a/src/Microsoft.DotNet.Arcade.Sdk/tools/BeforeNETSdkTargets.targets b/src/Microsoft.DotNet.Arcade.Sdk/tools/BeforeNETSdkTargets.targets new file mode 100644 index 00000000000..84b2020b612 --- /dev/null +++ b/src/Microsoft.DotNet.Arcade.Sdk/tools/BeforeNETSdkTargets.targets @@ -0,0 +1,4 @@ + + + + diff --git a/src/Microsoft.DotNet.Arcade.Sdk/tools/RuntimeIdentifierInference.BeforeNETSdkTargets.targets b/src/Microsoft.DotNet.Arcade.Sdk/tools/RuntimeIdentifierInference.BeforeNETSdkTargets.targets new file mode 100644 index 00000000000..359d4cbe352 --- /dev/null +++ b/src/Microsoft.DotNet.Arcade.Sdk/tools/RuntimeIdentifierInference.BeforeNETSdkTargets.targets @@ -0,0 +1,49 @@ + + + + <_EnableArcadeRuntimeIdentifierInference>$(EnableArcadeRuntimeIdentifierInference) + + + <_EnableArcadeRuntimeIdentifierInference Condition="'$(_EnableArcadeRuntimeIdentifierInference)' == '' and '$(RuntimeIdentifier)' != ''">false + + + <_RidAgnosticProject Condition="('$(OutputType)' == 'Library' or '$(IsTestProject)' == 'true') and '$(RuntimeIdentifiers)' == ''">true + + + <_EnableArcadeRuntimeIdentifierInference Condition="'$(_EnableArcadeRuntimeIdentifierInference)' == '' and ('$(IsRidAgnostic)' == 'true' or '$(_RidAgnosticProject)' == 'true')">false + + + <_EnableArcadeRuntimeIdentifierInference Condition="'$(_EnableArcadeRuntimeIdentifierInference)' == '' and '$(DotNetBuild)' == 'true'">true + + <_EnableArcadeRuntimeIdentifierFilters Condition="'$(EnableArcadeRuntimeIdentifierFilters)' != ''">$(EnableArcadeRuntimeIdentifierFilters) + + + <_EnableArcadeRuntimeIdentifierFilters Condition="'$(_EnableArcadeRuntimeIdentifierFilters)' == '' and '$(_EnableArcadeRuntimeIdentifierInference)' == 'true'">$(_EnableArcadeRuntimeIdentifierFilters) + + + + + false + $(TargetRid) + + + true + + + + <_ExplicitlySpecifiedRuntimeIdentifiers>;$(RuntimeIdentifiers); + + <_SuppressAllTargets Condition="'$(DisableArcadeExcludeFromBuildSupport)' != 'true' and $(_ExplicitlySpecifiedRuntimeIdentifiers).Contains(';$(TargetRid);')) == 'false'">true + + + $(RuntimeIdentifier) + + diff --git a/src/Microsoft.DotNet.Arcade.Sdk/tools/Settings.props b/src/Microsoft.DotNet.Arcade.Sdk/tools/Settings.props index b19ed1c3e57..0b1d6c41d43 100644 --- a/src/Microsoft.DotNet.Arcade.Sdk/tools/Settings.props +++ b/src/Microsoft.DotNet.Arcade.Sdk/tools/Settings.props @@ -6,6 +6,7 @@ <_ArcadeOverriddenCustomBeforeMicrosoftCommonCrossTargetingTargets>$(CustomBeforeMicrosoftCommonCrossTargetingTargets) $(MSBuildThisFileDirectory)BeforeCommonTargets.targets $(MSBuildThisFileDirectory)BeforeCommonTargets.CrossTargeting.targets + $(BeforeMicrosoftNETSdkTargets);$(MSBuildThisFileDirectory)BeforeNETSdkTargets.targets From 1f1594ed9354aad19f256288085a91e7911170aa Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 2 Jan 2025 15:18:45 -0800 Subject: [PATCH 2/4] Filter based on BaseOS when it is provided. --- ...entifierInference.BeforeNETSdkTargets.targets | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.DotNet.Arcade.Sdk/tools/RuntimeIdentifierInference.BeforeNETSdkTargets.targets b/src/Microsoft.DotNet.Arcade.Sdk/tools/RuntimeIdentifierInference.BeforeNETSdkTargets.targets index 359d4cbe352..415d19e6663 100644 --- a/src/Microsoft.DotNet.Arcade.Sdk/tools/RuntimeIdentifierInference.BeforeNETSdkTargets.targets +++ b/src/Microsoft.DotNet.Arcade.Sdk/tools/RuntimeIdentifierInference.BeforeNETSdkTargets.targets @@ -22,7 +22,7 @@ <_EnableArcadeRuntimeIdentifierInference Condition="'$(_EnableArcadeRuntimeIdentifierInference)' == '' and '$(DotNetBuild)' == 'true'">true <_EnableArcadeRuntimeIdentifierFilters Condition="'$(EnableArcadeRuntimeIdentifierFilters)' != ''">$(EnableArcadeRuntimeIdentifierFilters) - + @@ -39,9 +39,21 @@ + <_ExplicitlySpecifiedRuntimeIdentifiers>;$(RuntimeIdentifiers); + + + <_FilterRuntimeIdentifier>$(TargetRid) + + <_FilterRuntimeIdentifier Condition="'$(BaseOS)' != ''">$(BaseOS) + - <_SuppressAllTargets Condition="'$(DisableArcadeExcludeFromBuildSupport)' != 'true' and $(_ExplicitlySpecifiedRuntimeIdentifiers).Contains(';$(TargetRid);')) == 'false'">true + <_SuppressAllTargets Condition="'$(DisableArcadeExcludeFromBuildSupport)' != 'true' and $(_ExplicitlySpecifiedRuntimeIdentifiers).Contains(';$(_FilterRuntimeIdentifier);')) == 'false'">true $(RuntimeIdentifier) From e66960109cb21693980c0e5284428b127630e443 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 2 Jan 2025 15:55:13 -0800 Subject: [PATCH 3/4] Clean up IsRidAgnostic handling and add a new UB control property to enable the experience (which the orchestrator will set for the correct repos). --- Documentation/UnifiedBuild/Unified-Build-Controls.md | 1 + ...imeIdentifierInference.BeforeNETSdkTargets.targets | 11 +++++++---- .../tools/SourceBuild/SourceBuildArcadeBuild.targets | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Documentation/UnifiedBuild/Unified-Build-Controls.md b/Documentation/UnifiedBuild/Unified-Build-Controls.md index 809d94443d7..872e1416761 100644 --- a/Documentation/UnifiedBuild/Unified-Build-Controls.md +++ b/Documentation/UnifiedBuild/Unified-Build-Controls.md @@ -135,6 +135,7 @@ These controls may be used for **infrastructure or product purposes**. | -------- | -------- | -------- | -------- | | DotNetBuildWithOnlineSources | "true", "false", "" | "false" by default when `SourceOnly` switch is active. | When "true", do not remove non-local input sources. Infrastructure switch only. This switch is only exposed at the orchestrator level.
This replaces the existing `DotNetBuildOffline` switch. | | DotNetBuildSourceOnly | "true", "false", "" | "" | When "true", build only from source. Online sources may remain unless `DotNetBuildOffline` is set to true. This is both an infrastructure and a product switch.
This is roughly equivalent to `DotNetBuildFromSource` in the current infrastructure, though other controls may be better suited. | +| DotNetBuildTargetRidOnly | "true", "false", "" | "" | When not set, defaults to "true" if the repository build transitively depends on dotnet/runtime and `DotNetBuildOrchestrator` == "true"; otherwise "false". When "true", builds projects for the current `TargetRid` instead of using the current runtime identifier. | ### Output Controls diff --git a/src/Microsoft.DotNet.Arcade.Sdk/tools/RuntimeIdentifierInference.BeforeNETSdkTargets.targets b/src/Microsoft.DotNet.Arcade.Sdk/tools/RuntimeIdentifierInference.BeforeNETSdkTargets.targets index 415d19e6663..c1fcbf9cc93 100644 --- a/src/Microsoft.DotNet.Arcade.Sdk/tools/RuntimeIdentifierInference.BeforeNETSdkTargets.targets +++ b/src/Microsoft.DotNet.Arcade.Sdk/tools/RuntimeIdentifierInference.BeforeNETSdkTargets.targets @@ -1,12 +1,15 @@ - <_EnableArcadeRuntimeIdentifierInference>$(EnableArcadeRuntimeIdentifierInference) + <_EnableArcadeRuntimeIdentifierInference Condition="'$(_EnableArcadeRuntimeIdentifierInference)' == ''">$(EnableArcadeRuntimeIdentifierInference) <_EnableArcadeRuntimeIdentifierInference Condition="'$(_EnableArcadeRuntimeIdentifierInference)' == '' and '$(RuntimeIdentifier)' != ''">false - + <_RidAgnosticProject Condition="('$(OutputType)' == 'Library' or '$(IsTestProject)' == 'true') and '$(RuntimeIdentifiers)' == ''">true @@ -19,7 +22,7 @@ To avoid this, we'll default to setting the RID to the vertical's target RID. To preserve expected behavior for projects that don't specify a RID in a non-vertical build, we won't append the RID to the output path if the user hasn't explicitly requested it. --> - <_EnableArcadeRuntimeIdentifierInference Condition="'$(_EnableArcadeRuntimeIdentifierInference)' == '' and '$(DotNetBuild)' == 'true'">true + <_EnableArcadeRuntimeIdentifierInference Condition="'$(_EnableArcadeRuntimeIdentifierInference)' == '' and '$(DotNetBuildTargetRidOnly)' == 'true'">true <_EnableArcadeRuntimeIdentifierFilters Condition="'$(EnableArcadeRuntimeIdentifierFilters)' != ''">$(EnableArcadeRuntimeIdentifierFilters) @@ -35,7 +38,7 @@ $(TargetRid) - true + true diff --git a/src/Microsoft.DotNet.Arcade.Sdk/tools/SourceBuild/SourceBuildArcadeBuild.targets b/src/Microsoft.DotNet.Arcade.Sdk/tools/SourceBuild/SourceBuildArcadeBuild.targets index 76e314d1fad..a94d4e5acac 100644 --- a/src/Microsoft.DotNet.Arcade.Sdk/tools/SourceBuild/SourceBuildArcadeBuild.targets +++ b/src/Microsoft.DotNet.Arcade.Sdk/tools/SourceBuild/SourceBuildArcadeBuild.targets @@ -55,6 +55,7 @@ - DotNetBuildSourceOnly - Build from source only. Pass through outer build value if present. --> $(InnerBuildArgs) /p:DotNetBuildInnerRepo=true $(InnerBuildArgs) /p:DotNetBuildSourceOnly=$(DotNetBuildSourceOnly) + $(InnerBuildArgs) /p:DotNetBuildTargetRidOnly=$(DotNetBuildTargetRidOnly) $(InnerBuildArgs) /p:RepoRoot="$(InnerSourceBuildRepoRoot)$(_DirSeparatorEscapedCharForExecArg)" From 5b130d3597363d1981f863f76b9855c5b76e4f49 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 15 Jan 2025 15:43:19 -0800 Subject: [PATCH 4/4] Don't infer RIDs when the project that's building doesn't need a RID. --- ...dentifierInference.BeforeNETSdkTargets.targets | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Microsoft.DotNet.Arcade.Sdk/tools/RuntimeIdentifierInference.BeforeNETSdkTargets.targets b/src/Microsoft.DotNet.Arcade.Sdk/tools/RuntimeIdentifierInference.BeforeNETSdkTargets.targets index c1fcbf9cc93..9eba3fad9b4 100644 --- a/src/Microsoft.DotNet.Arcade.Sdk/tools/RuntimeIdentifierInference.BeforeNETSdkTargets.targets +++ b/src/Microsoft.DotNet.Arcade.Sdk/tools/RuntimeIdentifierInference.BeforeNETSdkTargets.targets @@ -15,6 +15,21 @@ <_EnableArcadeRuntimeIdentifierInference Condition="'$(_EnableArcadeRuntimeIdentifierInference)' == '' and ('$(IsRidAgnostic)' == 'true' or '$(_RidAgnosticProject)' == 'true')">false + + <_BuildFlavorRequiredRid + Condition=" + '$(SelfContained)' == 'true' or + ('$(_IsPublishing)' == 'true' and + ( + '$(PublishReadyToRun)' == 'true' or + '$(PublishSingleFile)' == 'true' or + '$(PublishAot)' == 'true' + ) + )">true + <_EnableArcadeRuntimeIdentifierInference Condition="'$(_EnableArcadeRuntimeIdentifierInference)' == '' and '$(_BuildFlavorRequiredRid)' != 'true'">false +