Repository navigation
Skip test-runtime install on cross-architecture builds - #55460
Conversation
On cross-build CI legs (e.g. x64 host building for arm64), the restore scripts were installing target-architecture runtimes into the host .dotnet folder. This caused libhostpolicy load failures when the NuGet credential provider tried to resolve a shared framework built for the wrong CPU architecture, breaking dotnet tool restore. Skip installing test runtimes entirely when the target architecture differs from the host (since the built product won't run on the build machine anyway). Preserve the macOS Rosetta 2 exception where x64 binaries can run on arm64. Port of the fix from release/dnup (PR dotnet#55435) to main. Fixes dotnet#55457 Co-authored-by: Copilot <[email protected]>
|
Azure Pipelines: Successfully started running 1 pipeline(s). 2 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
This PR updates the SDK toolset restore scripts to avoid installing test shared frameworks into the repo-local .dotnet when the build is cross-architecture (host arch != TARGET_ARCHITECTURE). This prevents mixed-architecture shared frameworks in .dotnet, which can break dotnet tool restore (notably via NuGet credential provider plugin load failures).
Changes:
- Skip installing test runtimes when
TARGET_ARCHITECTUREdiffers from the host architecture (with a macOS/Rosetta exception in the bash script). - Simplify the PowerShell flow by removing the “fallback architecture” helper and gating runtime install behind a single
installTestRuntimescheck.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| eng/restore-toolset.sh | Skips test-runtime installation on cross-arch legs, with a Rosetta 2 exception intended to keep installing when x64 can run on arm64. |
| eng/restore-toolset.ps1 | Skips test-runtime installation when TARGET_ARCHITECTURE differs from the native architecture and removes the fallback-architecture helper. |
The only macOS cross-build leg (osx-x64 Official on arm64 host) has runTests: false, so the test runtimes are never used even if installed. Simplify by uniformly skipping test-runtime install on all cross-builds. Co-authored-by: Copilot <[email protected]>
|
@nagilson It turns out that the runtimes that are downloaded get copied to the helix test images and are necessary there. So I added a commit that downloads them to a separate folder when there's a host / target architecture mismatch, and then OverlaySdkOnLKG.targets copies them from there to the test .NET root. |
There was a problem hiding this comment.
Approved, new change LGTM but I can't approve because it's my PR. Need another approver @marcpopMSFT ?
Summary
On cross-build CI legs (e.g. x64 host building for arm64), the restore scripts install target-architecture runtimes into the host
.dotnetfolder. This causeslibhostpolicyload failures when the NuGet credential provider resolves a shared framework built for the wrong CPU architecture, breakingdotnet tool restore.Fix
Skip installing test runtimes entirely when
TARGET_ARCHITECTUREdiffers from the host architecture (since the built product won't run on the build machine anyway). Preserves the macOS Rosetta 2 exception where x64 binaries can run on arm64.Port of the fix from
release/dnup(PR #55435 by @dsplaisted) tomain.Fixes #55457