Skip to content

Commit a6362d4

Browse files
authored
Manually resolve ref and runtime packs instead of modifying the .NET SDK used in the build (#54147)
1 parent 87c0397 commit a6362d4

File tree

4 files changed

+25
-80
lines changed

4 files changed

+25
-80
lines changed

eng/helix/helix.proj

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@
115115

116116
<!--
117117
In inner (per-queue) builds, tell the Helix SDK to pack up our just-built App.Ref / App.Runtime layouts w/
118-
the current versions. Warning: When using RunHelix.ps1, .dotnet/ folder may contain older App.Ref and
119-
App.Runtime layouts.
118+
the current versions.
120119
-->
121120
<Target Name="IncludeAspNetRuntime" BeforeTargets="Gather">
122121
<MSBuild Projects="$(RepoRoot)src\Framework\App.Runtime\src\Microsoft.AspNetCore.App.Runtime.csproj"
@@ -129,8 +128,8 @@
129128
<SharedFxVersion>@(_ResolvedProductVersionInfo->'%(PackageVersion)')</SharedFxVersion>
130129
<_AppRefSubPath>$([System.IO.Path]::Combine('packs', 'Microsoft.AspNetCore.App.Ref', '$(SharedFxVersion)'))</_AppRefSubPath>
131130
<_AppRuntimeSubPath>$([System.IO.Path]::Combine('shared', 'Microsoft.AspNetCore.App', '$(SharedFxVersion)'))</_AppRuntimeSubPath>
132-
<_AppRefPath>$([MSBuild]::NormalizeDirectory('$(RepoRoot)', '.dotnet', '$(_AppRefSubPath)'))</_AppRefPath>
133-
<_AppRuntimePath>$([MSBuild]::NormalizeDirectory('$(RepoRoot)', '.dotnet', '$(_AppRuntimeSubPath)'))</_AppRuntimePath>
131+
<_AppRefPath>$([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'artifacts', 'obj', 'TargetingPack.Layout', '$(Configuration)', '$(_AppRefSubPath)'))</_AppRefPath>
132+
<_AppRuntimePath>$([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'artifacts', 'obj', 'SharedFx.Layout', '$(Configuration)', '$(TargetRuntimeIdentifier)', '$(_AppRuntimeSubPath)'))</_AppRuntimePath>
134133

135134
<!--
136135
Don't bother checking for App.Runtime layout because we want both and App.Ref project depends on the
@@ -147,7 +146,7 @@
147146
<Error Text="Targeting path location '$(_AppRefPath)' does not exist and some tests are guaranteed to fail."
148147
Condition=" !$(_AppRefPathExists) AND '$(DoNotRequireSharedFxHelix)' != true " />
149148

150-
<!-- Grab only the portions of the .dotnet/ tree built in this run and have Helix zip that up. -->
149+
<!-- Grab the ref pack and runtime pack that were just built and have Helix zip that up. -->
151150
<ItemGroup Condition=" $(_AppRefPathExists) ">
152151
<HelixCorrelationPayload Include="$(_AppRefPath)"
153152
Condition=" $(IsWindowsHelixQueue) "

eng/tools/GenerateFiles/Directory.Build.targets.in

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -115,35 +115,28 @@
115115
</KnownFrameworkReference>
116116
</ItemGroup>
117117

118-
<!-- Warn if the "just-built" ASP.NET Core shared framework does not exist. -->
119-
<Target Name="WarnAboutMissingSharedFramework"
120-
BeforeTargets="Restore;Build;Rebuild;RunTests;Test;VSTest;Pack"
121-
Condition=" $(UpdateAspNetCoreKnownFramework) ">
122-
<PropertyGroup>
123-
<!--
124-
Property (already normalized) from Arcade SDK's RepoLayout.props. This covers all projects using the
125-
Arcade SDK. Ignore $(LocalDotNetRoot) because that is set in root Directory.Build.props (where Arcade SDK
126-
is imported) and therefore doesn't cover additional projects.
127-
-->
128-
<_DotNetRoot Condition=" '$(DotNetRoot)' != '' ">$(DotNetRoot)</_DotNetRoot>
129-
<!--
130-
Environment variable from eng/common/tools.ps1 scripts. This covers tests and assets that do not use the
131-
Arcade SDK but are run from our build.* scripts.
132-
-->
133-
<_DotNetRoot Condition=" '$(_DotNetRoot)' == '' AND
134-
'$(DOTNET_INSTALL_DIR)' != '' ">$([MSBuild]::NormalizeDirectory('$(DOTNET_INSTALL_DIR)'))</_DotNetRoot>
135-
<!--
136-
Environment variable from root activate.* and Helix runtest.* scripts. This covers tests and assets on
137-
Helix agents and when run locally using 'msbuild' after activation.
138-
-->
139-
<_DotNetRoot Condition=" '$(_DotNetRoot)' == '' AND
140-
'$(DOTNET_ROOT)' != '' ">$([MSBuild]::NormalizeDirectory('$(DOTNET_ROOT)'))</_DotNetRoot>
141-
</PropertyGroup>
118+
<!-- When building and running locally, manually resolve the just-built frameworks. On Helix, let the SDK resolve the packs itself (they're laid out on top of the .NET SDK in the work items) -->
119+
<PropertyGroup Condition="$(UpdateAspNetCoreKnownFramework) and '$(HELIX_CORRELATION_PAYLOAD)' == ''">
120+
<EnableTargetingPackDownload>false</EnableTargetingPackDownload>
121+
<EnableRuntimePackDownload>false</EnableRuntimePackDownload>
122+
<GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks>
123+
</PropertyGroup>
142124

143-
<Error Text="Unable to determine dotnet root location." Condition=" '$(_DotNetRoot)' == '' " />
144-
<Error Text="Dotnet root location '$(_DotNetRoot)' does not exist." Condition=" !EXISTS('$(_DotNetRoot)') " />
145-
<Warning Text="Requested Microsoft.AspNetCore.App v${MicrosoftAspNetCoreAppRuntimeVersion} does not exist."
146-
Condition=" !EXISTS('$(_DotNetRoot)shared\Microsoft.AspNetCore.App\${MicrosoftAspNetCoreAppRuntimeVersion}') " />
125+
<Target Name="ResolveLiveBuiltAspnetCoreKnownFramework" Condition="$(UpdateAspNetCoreKnownFramework) and '$(HELIX_CORRELATION_PAYLOAD)' == ''" AfterTargets="ResolveFrameworkReferences">
126+
<Error Text="Requested Microsoft.AspNetCore.App v${MicrosoftAspNetCoreAppRefVersion} ref pack does not exist."
127+
Condition="!Exists('$(TargetingPackLayoutRoot)packs\Microsoft.AspNetCore.App.Ref\${MicrosoftAspNetCoreAppRefVersion}\data\FrameworkList.xml') " />
128+
<ItemGroup>
129+
<ResolvedTargetingPack Path="$(TargetingPackLayoutRoot)packs\Microsoft.AspNetCore.App.Ref\${MicrosoftAspNetCoreAppRefVersion}"
130+
NugetPackageVersion="${MicrosoftAspNetCoreAppRefVersion}"
131+
PackageDirectory="$(TargetingPackLayoutRoot)packs\Microsoft.AspNetCore.App.Ref\${MicrosoftAspNetCoreAppRefVersion}"
132+
Condition="'%(ResolvedTargetingPack.RuntimeFrameworkName)' == 'Microsoft.AspNetCore.App'" />
133+
<ResolvedRuntimePack PackageDirectory="$(SharedFrameworkLayoutRoot)shared\Microsoft.AspNetCore.App\${MicrosoftAspNetCoreAppRuntimeVersion}"
134+
Condition="'%(ResolvedRuntimePack.RuntimeFrameworkName)' == 'Microsoft.AspNetCore.App'" />
135+
<ResolvedFrameworkReference TargetingPackPath="$(TargetingPackLayoutRoot)packs\Microsoft.AspNetCore.App.Ref\${MicrosoftAspNetCoreAppRefVersion}"
136+
TargetingPackVersion="${MicrosoftAspNetCoreAppRefVersion}"
137+
RuntimePackPath="$(SharedFrameworkLayoutRoot)shared\Microsoft.AspNetCore.App\${MicrosoftAspNetCoreAppRuntimeVersion}"
138+
Condition="'%(Identity)' == 'Microsoft.AspNetCore.App'" />
139+
</ItemGroup>
147140
</Target>
148141

149142
<!--

src/Framework/App.Ref/src/Microsoft.AspNetCore.App.Ref.csproj

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ This package is an internal implementation of the .NET Core SDK and is not meant
9393
<PropertyGroup>
9494
<TargetingPackSubPath>packs\Microsoft.AspNetCore.App.Ref\$(PackageVersion)\</TargetingPackSubPath>
9595
<LayoutTargetDir>$(TargetingPackLayoutRoot)$(TargetingPackSubPath)</LayoutTargetDir>
96-
<LocalInstallationOutputPath>$(LocalDotNetRoot)$(TargetingPackSubPath)</LocalInstallationOutputPath>
9796

9897
<ArchiveOutputFileName>aspnetcore-targeting-pack-$(PackageVersion)-$(TargetRuntimeIdentifier)</ArchiveOutputFileName>
9998
<ArchiveOutputPath>$(InstallersOutputPath)$(ArchiveOutputFileName)$(ArchiveExtension)</ArchiveOutputPath>
@@ -107,7 +106,6 @@ This package is an internal implementation of the .NET Core SDK and is not meant
107106
GenerateFrameworkListFile;
108107
_ResolveTargetingPackContent;
109108
_BatchCopyToLayoutTargetDir;
110-
_InstallTargetingPackIntoLocalDotNet;
111109
_CreateTargetingPackArchive;
112110
</BuildDependsOn>
113111
<ResolveTargetingPackContentDependsOn>
@@ -244,25 +242,6 @@ This package is an internal implementation of the .NET Core SDK and is not meant
244242
<Message Importance="High" Text="$(MSBuildProjectName) -> $(LayoutTargetDir)" />
245243
</Target>
246244

247-
<Target Name="_CleanLocalDotNet" BeforeTargets="_InstallTargetingPackIntoLocalDotNet">
248-
<ItemGroup>
249-
<_ExtraDotNetFiles Include="$(LocalInstallationOutputPath)**\*.*"
250-
Exclude="@(RefPackContent->'$(LocalInstallationOutputPath)%(PackagePath)%(RecursiveDir)%(FileName)%(Extension)')" />
251-
</ItemGroup>
252-
<Delete Files="@(_ExtraDotNetFiles)" />
253-
</Target>
254-
255-
<!-- Workaround https://github.com/dotnet/sdk/issues/2910 by copying targeting pack into local installation. -->
256-
<Target Name="_InstallTargetingPackIntoLocalDotNet"
257-
Condition="'$(DotNetBuildFromSource)' != 'true'"
258-
Inputs="@(RefPackContent)"
259-
Outputs="@(RefPackContent->'$(LocalInstallationOutputPath)%(PackagePath)%(RecursiveDir)%(FileName)%(Extension)')">
260-
<Copy SourceFiles="@(RefPackContent)"
261-
DestinationFiles="@(RefPackContent->'$(LocalInstallationOutputPath)%(PackagePath)%(RecursiveDir)%(FileName)%(Extension)')"
262-
UseHardlinksIfPossible="true" />
263-
<Message Importance="High" Text="$(MSBuildProjectName) -> $(LocalInstallationOutputPath)" />
264-
</Target>
265-
266245
<Target Name="_CreateTargetingPackArchive"
267246
Inputs="@(RefPackContent)"
268247
Outputs="$(ArchiveOutputPath)">

src/Framework/App.Runtime/src/Microsoft.AspNetCore.App.Runtime.csproj

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ This package is an internal implementation of the .NET Core SDK and is not meant
172172
<SharedRuntimeSubPath>shared\$(SharedFxName)\$(SharedFxVersion)\</SharedRuntimeSubPath>
173173
<SharedFxLayoutTargetDir>$(SharedFrameworkLayoutRoot)$(SharedRuntimeSubPath)</SharedFxLayoutTargetDir>
174174
<RedistLayoutTargetDir>$(RedistSharedFrameworkLayoutRoot)$(SharedRuntimeSubPath)</RedistLayoutTargetDir>
175-
<LocalInstallationOutputPath>$(LocalDotNetRoot)$(SharedRuntimeSubPath)</LocalInstallationOutputPath>
176175

177176
<RuntimeListFileName>RuntimeList.xml</RuntimeListFileName>
178177
<RuntimeListOutputPath>$(BaseIntermediateOutputPath)$(RuntimeListFileName)</RuntimeListOutputPath>
@@ -202,7 +201,6 @@ This package is an internal implementation of the .NET Core SDK and is not meant
202201
_GenerateRuntimeListFile;
203202
_ResolveRuntimePackContent;
204203
_ResolveSharedFrameworkContent;
205-
_InstallFrameworkIntoLocalDotNet;
206204
_DownloadAndExtractDotNetRuntime;
207205
_BatchCopyToSharedFrameworkLayout;
208206
_BatchCopyToRedistLayout;
@@ -684,30 +682,6 @@ This package is an internal implementation of the .NET Core SDK and is not meant
684682
DestinationFolder="$(LayoutAspnetPath)" />
685683
</Target>
686684

687-
<Target Name="_CleanLocalDotNet" BeforeTargets="_InstallFrameworkIntoLocalDotNet">
688-
<ItemGroup>
689-
<_ExtraDotNetFiles Include="$(LocalInstallationOutputPath)**\*.*"
690-
Exclude="@(RefPackContent->'$(LocalInstallationOutputPath)%(FileName)%(Extension)')" />
691-
</ItemGroup>
692-
<Delete Files="@(_ExtraDotNetFiles)" />
693-
</Target>
694-
695-
<!--
696-
Required to workaround https://github.com/dotnet/core-setup/issues/4809. This copies the shared framework
697-
into the $reporoot/.dotnet folder so tests can run against the shared framework. This workaround is not
698-
needed in source build.
699-
-->
700-
<Target Name="_InstallFrameworkIntoLocalDotNet"
701-
Condition="'$(DotNetBuildFromSource)' != 'true'"
702-
Inputs="@(SharedFxContent)"
703-
Outputs="@(SharedFxContent->'$(LocalInstallationOutputPath)%(FileName)%(Extension)')">
704-
705-
<Copy SourceFiles="@(SharedFxContent)"
706-
DestinationFiles="@(SharedFxContent->'$(LocalInstallationOutputPath)%(FileName)%(Extension)')"
707-
UseHardlinksIfPossible="true" />
708-
<Message Importance="High" Text="$(MSbuildProjectFile) -> $(LocalInstallationOutputPath)" />
709-
</Target>
710-
711685
<Target Name="_CreateRedistCompositeArchive"
712686
Condition="'$(TargetOsName)' == 'linux' or '$(TargetOsName)' == 'linux-musl'"
713687
Inputs="$(CompositeTargetDir)"

0 commit comments

Comments
 (0)