Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eng/pipelines/templates/stages/vmr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ stages:
vmrBranch: ${{ variables.VmrBranch }}
pool: ${{ parameters.pool_Windows }}
targetOS: windows
targetArchitecture: x64
targetArchitecture: x86
useDevVersions: true # Use dev versions for CI validation of the experience.
runTests: false # Temporarily do not run tests. The nuget comparison fails for some non-obvious reason and needs further investigation. Mostly, I'm not sure why it ever passed. https://github.com/dotnet/sdk/issues/42920

Expand Down
3 changes: 3 additions & 0 deletions src/SourceBuild/content/repo-projects/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@
<!-- Indicate that the build is being run from the orchestrator -->
<BuildArgs>$(BuildArgs) /p:DotNetBuildOrchestrator=true</BuildArgs>

<!-- Pass down configuration properties -->
<BuildArgs>$(BuildArgs) /p:TargetRid=$(TargetRid)</BuildArgs>

<!-- Pass through DotNetBuildPass for join point vertical support. -->
<BuildArgs Condition="'$(DotNetBuildPass)' != '' and '$(DotNetBuildPass)' != '1'">$(BuildArgs) /p:DotNetBuildPass=$(DotNetBuildPass)</BuildArgs>

Expand Down
20 changes: 17 additions & 3 deletions src/SourceBuild/content/repo-projects/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@
</PropertyGroup>

<PropertyGroup>
<BuildCommand Condition="'$(BuildCommand)' == '' and '$(IsUtilityProject)' != 'true'">$(BuildScript) $(BuildActions) $(BuildArgs)</BuildCommand>

<!-- MinimalConsoleLogOutput determines if the repository build should be logged to a separate file or directly to the console.
Enable it by default as with prallel repository builds the log becomes non-readable. -->
<RepoConsoleLogFile>$(ArtifactsLogRepoDir)$(RepositoryName).log</RepoConsoleLogFile>
Expand Down Expand Up @@ -449,6 +447,20 @@
</ItemGroup>
</Target>

<Target Name="SetBuildProperties"
DependsOnTargets="GetTransitiveRepositoryReferences">
<PropertyGroup>
<!-- 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. This is necessary when the host (SDK) rid
is different from the target rid, i.e. when building win-x86 with a win-x64 SDK but only when consuming
live runtime. Exclude from source-only builds which don't use the portable RID format which causes the
ProcessFrameworkReferences not be able to restore for the given RID. -->
<BuildArgs Condition="'$(DotNetBuildSourceOnly)' != 'true' and '@(TransitiveRepositoryReference->AnyHaveMetadataValue('Identity', 'runtime'))' == 'true'">$(BuildArgs) /p:DotNetBuildTargetRidOnly=true</BuildArgs>

<BuildCommand Condition="'$(BuildCommand)' == '' and '$(IsUtilityProject)' != 'true'">$(BuildScript) $(BuildActions) $(BuildArgs)</BuildCommand>
</PropertyGroup>
</Target>

<Target Name="RepoBuild"
Inputs="$(MSBuildProjectFullPath)"
Outputs="$(BaseIntermediateOutputPath)Build.complete"
Expand All @@ -460,7 +472,8 @@
UpdateEngCommonFiles;
CreateBuildInputProps;
DiscoverBuiltSdkOverrides;
SetSourceBuiltSdkOverrides">
SetSourceBuiltSdkOverrides;
SetBuildProperties">
<Message Importance="High" Text="[$([System.DateTime]::Now.ToString('HH:mm:ss.ff'))] Building $(RepositoryName)" />
<Message Importance="High" Text="Running command:" />
<Message Importance="High" Text=" $(BuildCommand)" />
Expand Down Expand Up @@ -734,6 +747,7 @@
<Target Name="Build"
DependsOnTargets="
BuildRepoReferences;
SetBuildProperties;
RepoBuild;
LogRepoArtifacts;
CopyInnerBuildRestoredPackages;
Expand Down
2 changes: 0 additions & 2 deletions src/SourceBuild/content/repo-projects/razor.proj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
<!-- The toolset compiler doesn't get killed with 'build-server shutdown'.
Instead of disabling shared compilation, disable the toolset compiler package. -->
<BuildArgs>$(BuildArgs) /p:UsingToolMicrosoftNetCompilers=false</BuildArgs>
<!-- Pass down the target RID so we can create the correct apphost for the language servers. -->
<BuildArgs>$(BuildArgs) /p:TargetRid=$(TargetRid)</BuildArgs>
</PropertyGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/SourceBuild/content/repo-projects/roslyn.proj
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@
<!-- Use the repo root build script -->
<BuildScript>$(ProjectDirectory)build$(ShellExtension)</BuildScript>
</PropertyGroup>

<PropertyGroup Condition="'$(BuildOS)' == 'windows' and '$(UseOfficialBuildVersioning)' != 'false'">
<BuildArgs>$(BuildArgs) $(FlagParameterPrefix)officialBuildId $(OfficialBuildId)</BuildArgs>
<BuildArgs>$(BuildArgs) $(FlagParameterPrefix)officialSkipTests true</BuildArgs>
<BuildArgs>$(BuildArgs) $(FlagParameterPrefix)officialSkipApplyOptimizationData true</BuildArgs>
<BuildArgs>$(BuildArgs) $(FlagParameterPrefix)officialSourceBranchName placeholder</BuildArgs>
<BuildArgs>$(BuildArgs) $(FlagParameterPrefix)officialVisualStudioDropAccessToken placeholder</BuildArgs>
</PropertyGroup>

<PropertyGroup>
<BuildArgs Condition="'$(DotNetBuildSourceOnly)' != 'true'">$(BuildArgs) /p:TargetRid=$(TargetRid)</BuildArgs>
<BuildArgs>$(BuildArgs) /p:TreatWarningsAsErrors=false</BuildArgs>
<BuildArgs>$(BuildArgs) /p:ApplyPartialNgenOptimization=false</BuildArgs>
<BuildArgs>$(BuildArgs) /p:EnablePartialNgenOptimization=false</BuildArgs>
Expand Down
1 change: 0 additions & 1 deletion src/SourceBuild/content/repo-projects/runtime.proj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

<BuildArgs>$(BuildArgs) $(FlagParameterPrefix)arch $(TargetArchitecture)</BuildArgs>
<BuildArgs>$(BuildArgs) $(FlagParameterPrefix)os $(TargetOS)</BuildArgs>
<BuildArgs>$(BuildArgs) /p:TargetRid=$(TargetRid)</BuildArgs>
<BuildArgs Condition="'$(DotNetBuildRuntimeWasmEnableThreads)' == 'true'">$(BuildArgs) /p:DotNetBuildRuntimeWasmEnableThreads=true</BuildArgs>
<BuildArgs Condition="'$(DotNetBuildRuntimeNativeAOTRuntimePack)' == 'true'">$(BuildArgs) /p:DotNetBuildRuntimeNativeAOTRuntimePack=true</BuildArgs>
<BuildArgs Condition="'$(DotNetBuildMonoEnableLLVM)' != ''">$(BuildArgs) /p:DotNetBuildMonoEnableLLVM=$(DotNetBuildMonoEnableLLVM)</BuildArgs>
Expand Down
3 changes: 1 addition & 2 deletions src/SourceBuild/content/repo-projects/sdk.proj
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<Project Sdk="Microsoft.Build.NoTargets">
<Project Sdk="Microsoft.Build.NoTargets">

<PropertyGroup>
<LogVerbosityOptOut>true</LogVerbosityOptOut>

<BuildArgs Condition="'$(TargetOS)' == 'windows'">$(BuildArgs) -nativeToolsOnMachine</BuildArgs>
<BuildArgs>$(BuildArgs) /p:PackageProjectUrl=https://github.com/dotnet/sdk</BuildArgs>
<BuildArgs>$(BuildArgs) /p:PortableRid=$(PortableRid)</BuildArgs>
<BuildArgs>$(BuildArgs) /p:TargetRid=$(TargetRid)</BuildArgs>

<BuildArgs>$(BuildArgs) $(FlagParameterPrefix)v $(LogVerbosity)</BuildArgs>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
From 0b326d7d0d266808c6109282c6417d26835ef648 Mon Sep 17 00:00:00 2001
From: Jeremy Koritzinsky <[email protected]>
Date: Thu, 2 Jan 2025 12:19:02 -0800
Subject: [PATCH] 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.

Backport: https://github.com/dotnet/arcade/pull/15371

---
.../UnifiedBuild/Unified-Build-Controls.md | 1 +
.../tools/BeforeNETSdkTargets.targets | 4 +
...ifierInference.BeforeNETSdkTargets.targets | 79 +++++++++++++++++++
.../tools/Settings.props | 1 +
.../SourceBuildArcadeBuild.targets | 1 +
5 files changed, 86 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/Documentation/UnifiedBuild/Unified-Build-Controls.md b/Documentation/UnifiedBuild/Unified-Build-Controls.md
index 809d94443..872e14167 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.</br>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.<br/>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/BeforeNETSdkTargets.targets b/src/Microsoft.DotNet.Arcade.Sdk/tools/BeforeNETSdkTargets.targets
new file mode 100644
index 000000000..84b2020b6
--- /dev/null
+++ b/src/Microsoft.DotNet.Arcade.Sdk/tools/BeforeNETSdkTargets.targets
@@ -0,0 +1,4 @@
+<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. -->
+<Project>
+ <Import Project="RuntimeIdentifierInference.BeforeNETSdkTargets.targets" />
+</Project>
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 000000000..9eba3fad9
--- /dev/null
+++ b/src/Microsoft.DotNet.Arcade.Sdk/tools/RuntimeIdentifierInference.BeforeNETSdkTargets.targets
@@ -0,0 +1,79 @@
+<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. -->
+<Project>
+ <PropertyGroup>
+ <_EnableArcadeRuntimeIdentifierInference Condition="'$(_EnableArcadeRuntimeIdentifierInference)' == ''">$(EnableArcadeRuntimeIdentifierInference)</_EnableArcadeRuntimeIdentifierInference>
+
+ <!-- If the user has specified a RID for their project, don't overwrite it. -->
+ <_EnableArcadeRuntimeIdentifierInference Condition="'$(_EnableArcadeRuntimeIdentifierInference)' == '' and '$(RuntimeIdentifier)' != ''">false</_EnableArcadeRuntimeIdentifierInference>
+
+ <!--
+ If the SDK will infer this project as "RID agnostic", don't infer RIDs.
+ This should generally match the logic for setting IsRidAgnostic in the SDK.
+ -->
+ <_RidAgnosticProject Condition="('$(OutputType)' == 'Library' or '$(IsTestProject)' == 'true') and '$(RuntimeIdentifiers)' == ''">true</_RidAgnosticProject>
+
+ <!-- If this project is RID-agnostic, don't infer RIDs. -->
+ <_EnableArcadeRuntimeIdentifierInference Condition="'$(_EnableArcadeRuntimeIdentifierInference)' == '' and ('$(IsRidAgnostic)' == 'true' or '$(_RidAgnosticProject)' == 'true')">false</_EnableArcadeRuntimeIdentifierInference>
+
+ <!--
+ We only need to infer if the project would use the RID
+ -->
+ <_BuildFlavorRequiredRid
+ Condition="
+ '$(SelfContained)' == 'true' or
+ ('$(_IsPublishing)' == 'true' and
+ (
+ '$(PublishReadyToRun)' == 'true' or
+ '$(PublishSingleFile)' == 'true' or
+ '$(PublishAot)' == 'true'
+ )
+ )">true</_BuildFlavorRequiredRid>
+ <_EnableArcadeRuntimeIdentifierInference Condition="'$(_EnableArcadeRuntimeIdentifierInference)' == '' and '$(_BuildFlavorRequiredRid)' != 'true'">false</_EnableArcadeRuntimeIdentifierInference>
+
+ <!--
+ When we're doing a build of a single vertical, we may not have a runtime or host available for any RID outside of our current target.
+ For many of our projects, we don't actually need to build any RID-specific assets, but the SDK may still try to pull down assets for other RIDs,
+ in particular for the RID matching the SDK's RID.
+ 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 '$(DotNetBuildTargetRidOnly)' == 'true'">true</_EnableArcadeRuntimeIdentifierInference>
+
+ <_EnableArcadeRuntimeIdentifierFilters Condition="'$(EnableArcadeRuntimeIdentifierFilters)' != ''">$(EnableArcadeRuntimeIdentifierFilters)</_EnableArcadeRuntimeIdentifierFilters>
+
+ <!--
+ If we infer a RID for the project, default to filtering down the list of RIDs the project specifies and automatically excluding projects that don't build for this RID.
+ -->
+ <_EnableArcadeRuntimeIdentifierFilters Condition="'$(_EnableArcadeRuntimeIdentifierFilters)' == '' and '$(_EnableArcadeRuntimeIdentifierInference)' == 'true'">$(_EnableArcadeRuntimeIdentifierFilters)</_EnableArcadeRuntimeIdentifierFilters>
+ </PropertyGroup>
+
+ <PropertyGroup Condition="'$(_EnableArcadeRuntimeIdentifierInference)' == 'true'">
+ <!-- If we're inferring a RID, regular builds wouldn't have appended the RID to the output path. Default to not appending to the output path to preserve expected output locations. -->
+ <AppendRuntimeIdentifierToOutputPath Condition="'$(AppendRuntimeIdentifierToOutputPath)' == ''">false</AppendRuntimeIdentifierToOutputPath>
+ <RuntimeIdentifier>$(TargetRid)</RuntimeIdentifier>
+
+ <!-- If this project would have been inferred as "RID agnostic", preserve that as well. -->
+ <IsRidAgnostic Condition="'$(_RidAgnosticProject)' == 'true'">true</IsRidAgnostic>
+ </PropertyGroup>
+
+ <PropertyGroup Condition="'$(_EnableArcadeRuntimeIdentifierFilters)' == 'true' and '$(RuntimeIdentifiers)' != ''">
+ <!-- Prepend and append with semicolons to make the Contains call below simpler. -->
+ <_ExplicitlySpecifiedRuntimeIdentifiers>;$(RuntimeIdentifiers);</_ExplicitlySpecifiedRuntimeIdentifiers>
+
+ <!--
+ Sometimes we may need to filter the RuntimeIdentifiers list by a RID that is not TargetRid.
+ Determine which RID to filter on here.
+
+ We can't actually use the RID graph here as RID graph filtering is only possible in a task, and we need to do this during property evaluation.
+ -->
+ <_FilterRuntimeIdentifier>$(TargetRid)</_FilterRuntimeIdentifier>
+ <!-- If we're introducing a new runtime identifier with TargetRid, filter instead on BaseOS. -->
+ <_FilterRuntimeIdentifier Condition="'$(BaseOS)' != ''">$(BaseOS)</_FilterRuntimeIdentifier>
+
+ <!-- If a project builds for a set of RIDs specified in the project file and this vertical isn't in the list, suppress building this project. -->
+ <_SuppressAllTargets Condition="'$(DisableArcadeExcludeFromBuildSupport)' != 'true' and $(_ExplicitlySpecifiedRuntimeIdentifiers).Contains(';$(_FilterRuntimeIdentifier);')) == 'false'">true</_SuppressAllTargets>
+
+ <!-- The .NET SDK will try to restore for all specified RIDs. Change the list of RIDs to only our inferred RID to ensure that restore only restores assets that could be available. -->
+ <RuntimeIdentifiers>$(RuntimeIdentifier)</RuntimeIdentifiers>
+ </PropertyGroup>
+</Project>
diff --git a/src/Microsoft.DotNet.Arcade.Sdk/tools/Settings.props b/src/Microsoft.DotNet.Arcade.Sdk/tools/Settings.props
index b19ed1c3e..0b1d6c41d 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)</_ArcadeOverriddenCustomBeforeMicrosoftCommonCrossTargetingTargets>
<CustomBeforeMicrosoftCommonTargets>$(MSBuildThisFileDirectory)BeforeCommonTargets.targets</CustomBeforeMicrosoftCommonTargets>
<CustomBeforeMicrosoftCommonCrossTargetingTargets>$(MSBuildThisFileDirectory)BeforeCommonTargets.CrossTargeting.targets</CustomBeforeMicrosoftCommonCrossTargetingTargets>
+ <BeforeMicrosoftNETSdkTargets>$(BeforeMicrosoftNETSdkTargets);$(MSBuildThisFileDirectory)BeforeNETSdkTargets.targets</BeforeMicrosoftNETSdkTargets>
<!-- MSBuild has "global" variables (ie command-line or MSBuild task properties) override local declarations. That's generally not the behavior that we want in Arcade.
We want to be able to have Arcade MSBuild a project / target with the property set as a default, but let the project override that value. To work around MSBuild,
we pass in `_blah` and set it to a local property (`blah`) which is not global. -->
diff --git a/src/Microsoft.DotNet.Arcade.Sdk/tools/SourceBuild/SourceBuildArcadeBuild.targets b/src/Microsoft.DotNet.Arcade.Sdk/tools/SourceBuild/SourceBuildArcadeBuild.targets
index 76e314d1f..a94d4e5ac 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 Condition="'$(DotNetBuildRepo)' == 'true'">$(InnerBuildArgs) /p:DotNetBuildInnerRepo=true</InnerBuildArgs>
<InnerBuildArgs Condition="'$(DotNetBuildSourceOnly)' != ''">$(InnerBuildArgs) /p:DotNetBuildSourceOnly=$(DotNetBuildSourceOnly)</InnerBuildArgs>
+ <InnerBuildArgs Condition="'$(DotNetBuildTargetRidOnly)' != ''">$(InnerBuildArgs) /p:DotNetBuildTargetRidOnly=$(DotNetBuildTargetRidOnly)</InnerBuildArgs>
<!-- Use a fresh clone of the repo so that source-build modifications are isolated. -->
<InnerBuildArgs>$(InnerBuildArgs) /p:RepoRoot="$(InnerSourceBuildRepoRoot)$(_DirSeparatorEscapedCharForExecArg)"</InnerBuildArgs>
<!-- Override the artifacts dir to cleanly separate the inner build from outer build. -->
Loading
Loading