Refactor build.cmd for ARM64 and add build.cmd.ps1#14702
Refactor build.cmd for ARM64 and add build.cmd.ps1#14702KlausLoeffelmann wants to merge 1 commit into
Conversation
* Refactored build.cmd to delegate to a new PowerShell script (build.cmd.ps1) for improved argument parsing and platform detection. * Added support for building on Windows ARM64 via the -platform arm64 option, which sets TargetArchitecture and disables NativeToolsOnMachine. * Updated documentation to reflect the new ARM64 build instructions.
|
@Olina-Zhang, @LeafShi1, @Shyam-Gupta:
This introduces a different batch file, which is picked up when you build locally on ARM (tested on a Surface X, work fine). If there is a better way to do this, please advise and then feel free to close the PR. Thanks! |
There was a problem hiding this comment.
Pull request overview
Refactors the repository’s root build.cmd entrypoint to delegate to a new eng/build.cmd.ps1 wrapper, aiming to improve argument handling and add guidance for building on Windows ARM64.
Changes:
- Added
eng/build.cmd.ps1to preprocess arguments (notably ARM64) before invokingeng/common/build.ps1. - Updated
build.cmdto call the new PowerShell wrapper instead of callingeng/common/build.ps1directly. - Updated
docs/building.mdwith Windows ARM64 build instructions.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| eng/build.cmd.ps1 | New wrapper script for build argument parsing and ARM64 detection before invoking eng/common/build.ps1. |
| build.cmd | Delegates to eng/build.cmd.ps1. |
| docs/building.md | Documents ARM64 build invocation via -platform arm64. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if ($arg.Equals('-platform', [StringComparison]::OrdinalIgnoreCase) -and | ||
| $i + 1 -lt $BuildArgs.Length -and | ||
| $BuildArgs[$i + 1].Equals('arm64', [StringComparison]::OrdinalIgnoreCase)) { | ||
| $isArm64Platform = $true | ||
| $i++ | ||
| continue | ||
| } | ||
|
|
||
| if ($arg.Equals('/p:Platform=arm64', [StringComparison]::OrdinalIgnoreCase) -or | ||
| $arg.Equals('-p:Platform=arm64', [StringComparison]::OrdinalIgnoreCase)) { | ||
| $isArm64Platform = $true | ||
| continue | ||
| } |
| } | ||
| } | ||
|
|
||
| $buildScript = Join-Path $PSScriptRoot 'common\Build.ps1' |
|
|
||
| * Run `.\build.cmd` from the repository root. This builds the `Winforms.sln` using the default config (Debug|Any CPU). | ||
| * To specify a build configuration, add `-configuration` followed by the config such as `.\build -configuration Release`. | ||
| * To build on Windows ARM64, use `.\build -platform arm64`. This maps the solution platform to `TargetArchitecture=arm64` without promoting local Visual Studio native tool paths. |
I did a quick comparison between the current code and this PR. On my x64 machine, build -configuration release -platform ARM64 already succeeds and Platform=ARM64 appears in the generated binlog. With this change, I additionally see TargetArchitecture=arm64 being propagated. Was the issue primarily reproducible on native ARM64 devices (e.g. Surface X), or was the main problem that TargetArchitecture was not being set correctly for ARM builds? |
|
@KlausLoeffelmann we have a known issue: #12207 when using I tested |

Refactored
build.cmdto delegate to a new PowerShell script (build.cmd.ps1) for improved argument parsing and platform detection.Added support for building on Windows ARM64 via the
-platform arm64option, which sets TargetArchitecture and disables NativeToolsOnMachine.Updated documentation to reflect the new ARM64 build instructions.
Microsoft Reviewers: Open in CodeFlow