Skip to content

Refactor build.cmd for ARM64 and add build.cmd.ps1#14702

Open
KlausLoeffelmann wants to merge 1 commit into
dotnet:mainfrom
KlausLoeffelmann:repairBuildArm64Locally
Open

Refactor build.cmd for ARM64 and add build.cmd.ps1#14702
KlausLoeffelmann wants to merge 1 commit into
dotnet:mainfrom
KlausLoeffelmann:repairBuildArm64Locally

Conversation

@KlausLoeffelmann

@KlausLoeffelmann KlausLoeffelmann commented Jul 5, 2026

Copy link
Copy Markdown
Member
  • 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.

Microsoft Reviewers: Open in CodeFlow

* 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.
@KlausLoeffelmann

KlausLoeffelmann commented Jul 5, 2026

Copy link
Copy Markdown
Member Author

@Olina-Zhang, @LeafShi1, @Shyam-Gupta:
I needed to test the new planned APIs for .NET 11 on a locally compiled ARM build, but could not make it work out of the box.

build -configuration release -platform ARM64 did not work.

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!

@KlausLoeffelmann KlausLoeffelmann requested review from Copilot and removed request for a team July 5, 2026 17:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ps1 to preprocess arguments (notably ARM64) before invoking eng/common/build.ps1.
  • Updated build.cmd to call the new PowerShell wrapper instead of calling eng/common/build.ps1 directly.
  • Updated docs/building.md with 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.

Comment thread eng/build.cmd.ps1
Comment on lines +20 to +32
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
}
Comment thread eng/build.cmd.ps1
}
}

$buildScript = Join-Path $PSScriptRoot 'common\Build.ps1'
Comment thread docs/building.md

* 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.
@LeafShi1

LeafShi1 commented Jul 6, 2026

Copy link
Copy Markdown
Member

@Olina-Zhang, @LeafShi1, @Shyam-Gupta: I needed to test the new planned APIs for .NET 11 on a locally compiled ARM build, but could not make it work out of the box.

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?

@Olina-Zhang

Olina-Zhang commented Jul 7, 2026

Copy link
Copy Markdown
Member

@KlausLoeffelmann we have a known issue: #12207 when using build.cmd for main branch of Winforms repo on arm64 VM.

I tested build -configuration release -platform ARM64 for your this branch on arm64 VM, also failed as following:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants