Repository navigation
Enhance ARM64 build scripts and architecture handling - #15314
Open
KlausLoeffelmann wants to merge 3 commits into
Open
KlausLoeffelmann wants to merge 3 commits into
KlausLoeffelmann wants to merge 3 commits into
Conversation
- Switch build.cmd to use build.cmd.ps1 for improved argument parsing and ARM64 detection. - Add logic to remove mismatched hostfxr.dll versions on ARM64, ensuring correct architecture resolution and self-healing builds. - Pin CMake version to 3.21.0 in global.json for consistency. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 479cf8e8-6235-4ad2-8f8d-7d4bb931f24c
Separate OS, SDK execution, and target architectures to support native and cross-target builds on ARM64 and x64. Preserve compatible emulated SDKs, repair mixed runtime installations safely, and align restore and IDE launcher roots. Add regression checks to PR CI and document the architecture model. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved correctness issues affect architecture selection, runtime recovery and discovery, and build failure reporting.
7 open issues
Set architecture-specific DOTNET_ROOT values for command-line tests · New Normalize inferred target architecture to lowercase · New Detect all target architecture arguments before inferring defaults · New Return nonzero status when Arcade argument binding fails · New Repair hostfxr directories missing the resolver binary · New Validate required runtime payloads before reuse and after install · New Safely quote SDK roots ending with a backslash · New
What changed in this PR
This PR adds repository-owned architecture handling to WinForms build tooling, separating SDK execution architecture from build targets and runtime installations.
Changes:
- Adds architecture-aware SDK selection, runtime installation, and mixed-installation repair.
- Updates build wrappers, IDE launchers, and project defaults for x64, ARM64, and x86 targets.
- Documents the workflow and adds script regression checks to PR CI.
| File | Description |
|---|---|
start-vs.cmd |
Resolves SDK and runtime roots before launching Visual Studio. |
start-code.cmd |
Configures architecture-specific roots for VS Code. |
src/test/integration/ScratchProject/ScratchProject.csproj |
Derives the runtime identifier from the target architecture. |
Restore.cmd |
Routes restore through the new wrapper. |
global.json |
Prefers the host SDK location and generalizes runtime selection. |
eng/Tools.props |
Hooks the repository runtime installer into Arcade. |
eng/tests/DotNetArchitecture.Tests.ps1 |
Tests SDK selection, runtime isolation, and repair. |
eng/tests/BuildScript.Tests.ps1 |
Tests argument forwarding, architecture defaults, and exit codes. |
eng/pipelines/build-PR.yml |
Runs the new script regression checks. |
eng/install-runtimes.ps1 |
Installs manifest runtimes for SDK and target architectures. |
eng/dotnet-architecture.ps1 |
Implements architecture detection, directory routing, and repair. |
eng/configure-toolset.ps1 |
Integrates architecture-aware SDK bootstrap with Arcade. |
eng/build.cmd.ps1 |
Handles build arguments and supplies architecture defaults. |
docs/building.md |
Documents architecture selection, isolation, and recovery. |
Directory.Build.props |
Infers target architecture from platform and host settings. |
build.cmd |
Invokes the new build wrapper. |
Review effort: Balanced
| return $dotnetRoot | ||
| } | ||
|
|
||
| return Join-Path $dotnetRoot $runtimeArchitecture |
| <GenerateDocumentationFile>True</GenerateDocumentationFile> | ||
| <PublishWindowsPdb>false</PublishWindowsPdb> | ||
|
|
||
| <TargetArchitecture Condition="'$(TargetArchitecture)' == '' and ('$(Platform)' == 'arm64' or '$(Platform)' == 'x64' or '$(Platform)' == 'x86')">$(Platform)</TargetArchitecture> |
Comment on lines
+23
to
+33
| if ($arg -match '^[-/]p:TargetArchitecture=') { $hasTargetArchitecture = $true } | ||
| if ($arg -match '^-(restore|r)$') { $hasRestore = $true } | ||
| if ($arg -match '^-(build|b)$') { $hasBuild = $true } | ||
| if ($arg -match '^-(binaryLog|bl|binaryLogName|bln|excludeCIBinarylog|nobl)$') { $hasBinaryLog = $true } | ||
|
|
||
| if ($arg -eq '-platform' -and $i + 1 -lt $BuildArgs.Length) { | ||
| $targetArchitecture = $BuildArgs[$i + 1] | ||
| } | ||
| elseif ($arg -match '^[-/]p:Platform=(.+)$') { | ||
| $targetArchitecture = $Matches[1] | ||
| } |
| # -File cannot bind Boolean parameters in Windows PowerShell. Encode a command | ||
| # with quoted values and literal Boolean arguments instead of losing their types. | ||
| $buildScript = "$PSScriptRoot\common\build.ps1".Replace("'", "''") | ||
| $command = "`$ProgressPreference = 'SilentlyContinue'; & '$buildScript' -NativeToolsOnMachine" |
Comment on lines
+109
to
+111
| if (!(Test-Path -LiteralPath $binaryPath)) { | ||
| continue | ||
| } |
Comment on lines
+150
to
+152
| $complete = (Test-Path -LiteralPath $muxer) -and | ||
| (Test-Path -LiteralPath $coreclr) -and | ||
| (Test-Path -LiteralPath $resolver) |
| set DOTNET_ROOT(x86)=%~dp0.dotnet\x86 | ||
| if defined DOTNET_GLOBAL_INSTALL_DIR set "DOTNET_ROOT=%DOTNET_GLOBAL_INSTALL_DIR%" | ||
| set "__DotNetSdkRoot=" | ||
| for /f "delims=" %%r in ('powershell -NoProfile -ExecutionPolicy ByPass -File "%~dp0eng\dotnet-architecture.ps1" -ResolveSdkRoot "%DOTNET_ROOT%"') do set "__DotNetSdkRoot=%%r" |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #15314 +/- ##
=============================================
Coverage 37.84861% 37.84861%
=============================================
Files 246 246
Lines 9789 9789
Branches 1031 1031
=============================================
Hits 3705 3705
Misses 5920 5920
Partials 164 164
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Address ARM64 build review findings with architecture-specific apphost roots, reliable argument forwarding, runtime payload validation, and safe resolver repair. Add regression coverage for fresh installs and incomplete caches. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 60ae4767-5c06-4b45-ab0f-996e7d30e05a
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


This pull request introduces robust support for Windows x64 and ARM64 builds, improving how the repository handles SDK and runtime architecture isolation, installation, and repair. The changes ensure that builds and restores work seamlessly across architectures, correctly manage mixed or reused SDK installations, and provide new scripts and documentation to clarify and automate these processes. The update also adds regression tests to verify architecture handling in CI.
Build and architecture handling improvements:
eng/dotnet-architecture.ps1, a comprehensive script for detecting, installing, and repairing .NET SDK and runtime installations across x64, ARM64, and x86 architectures, including logic for handling reused or mixed-architecture SDKs and preserving incomplete/incompatible runtimes (eng/dotnet-architecture.ps1).eng/configure-toolset.ps1to use the new architecture detection and repair logic, ensuring that SDK installations match the host or specified architecture and are repaired as needed.eng/install-runtimes.ps1, which installs required .NET runtimes for the correct architecture(s) and ensures all runtime files are present and compatible.eng/Tools.propsto bypass default Arcade SDK cache checks and invoke the repository’s own runtime installer, ensuring correct runtime isolation and installation for WinForms projects.Build script and pipeline updates:
Build.ps1with a neweng/build.cmd.ps1script in bothbuild.cmdandRestore.cmd, which parses arguments, sets architecture defaults, and invokes the build with the correct configuration [1] [2] [3].Directory.Build.propsto set theTargetArchitectureproperty based on platform and OS, ensuring builds default to the correct architecture unless explicitly overridden.Documentation and CI enhancements:
docs/building.mdwith detailed guidance on Windows x64 and ARM64 builds, SDK/runtime installation behavior, and troubleshooting for mixed-architecture environments.eng/pipelines/build-PR.ymlto run new regression tests that verify proper SDK and runtime architecture isolation.These changes collectively improve cross-architecture support, reliability, and clarity for developers working with Windows .NET builds.
Microsoft Reviewers: Open in CodeFlow