Skip to content

Avoid rewriting unchanged ARM64 manifests behind Wave 18.14 - #15428

Merged
JanProvaznik merged 3 commits into
dotnet:mainfrom
JanProvaznik:janprovaznik-arm64-manifest-incrementality
Oct 30, 2026
Merged

JanProvaznik merged 3 commits into
dotnet:mainfrom
JanProvaznik:janprovaznik-arm64-manifest-incrementality

Conversation

@JanProvaznik

Copy link
Copy Markdown
Member

Related issue(s):

Fixes #15417

Context

With PreferNativeArm64=true, AddToWin32Manifest rewrites its generated manifest on every build. The new timestamp makes CoreCompile run even when the project is unchanged.

Changes Made

Serialize using the existing XML writer settings and write only when the bytes differ. Keep returning ManifestPath when the file is unchanged, so the compiler still receives the generated manifest path.

Add Wave 18.14, task-level timestamp and changed-input coverage, and second-build compiler checks in the existing end-to-end tests. Target definitions, library behavior, and cleanup are unchanged.

Compatibility

MSBUILDDISABLEFEATURESFROMVERSION=18.14 restores unconditional writes. Encoding, BOM, formatting, output paths, and task parameters are unchanged; no new diagnostics or public APIs.

Testing

  • .\build.cmd -v quiet: passed both build stages, with existing NuGet audit warnings.
  • dotnet build src\Tasks.UnitTests\Microsoft.Build.Tasks.UnitTests.csproj --no-restore -v:q -nr:false -p:UseSharedCompilation=false: passed.

Focused tests on both runtimes:

foreach ($tfm in @('net11.0', 'net472')) {
    & ".\artifacts\bin\Microsoft.Build.Tasks.UnitTests\Debug\$tfm\Microsoft.Build.Tasks.UnitTests.exe" --filter-class '*AddToWin32Manifest_Tests' --no-progress
    & ".\artifacts\bin\Microsoft.Build.Engine.UnitTests\Debug\$tfm\Microsoft.Build.Engine.UnitTests.exe" --filter-class '*ChangeWaves_Tests' --no-progress
}

Manifest tests: 13 passed per runtime. Change-wave tests: 20 passed per runtime. No skips.

Red/green verified by temporarily restoring the original writer: both runtimes produced the same four expected failures (two timestamp checks and two repeated-compilation checks). Restoring the fix made all 13 manifest tests pass. Timestamp unit tests use an explicitly old timestamp rather than sleeps.

The full repository test suite was not run.

Dependencies and Follow-up

None.

Write generated Win32 manifests only when their bytes change, while retaining unconditional writes when Wave 18.14 is disabled. Keep returning the generated manifest path on unchanged builds.

Add task and incremental compilation regression coverage and document the opt-out. Refs dotnet#15417.

Co-authored-by: Copilot App <[email protected]>

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.

🟡 Changes recommended

The new behavior uses Wave18_14 despite the repository being at 18.13.0, incorrectly assigning a future-version opt-out instead of the required Wave18_13.

1 open issue
What changed in this PR

This PR addresses #15417 by avoiding rewrites of unchanged ARM64 manifests, allowing MSBuild to skip compilation on subsequent unchanged builds.

Changes:

  • Compares serialized manifest bytes before writing, while preserving ManifestPath.
  • Gates timestamp preservation behind Wave 18.14 and documents the opt-out.
  • Adds timestamp, changed-input, and repeated-build compiler checks.
File Description
src/​Tasks/​AddToWin32Manifest.cs Writes generated manifests only when bytes differ and the wave is enabled.
src/​Tasks.UnitTests/​AddToWin32Manifest_Tests.cs Tests timestamp preservation, opt-out behavior, changed inputs, and incremental compilation.
src/​Framework/​ChangeWaves.cs Registers Wave 18.14.
documentation/​wiki/​ChangeWaves.md Documents manifest timestamp preservation and its opt-out.

Review effort: Balanced

Comment thread src/Framework/ChangeWaves.cs Resolved
Comment thread src/Tasks/AddToWin32Manifest.cs Resolved
Use MemoryStream.TryGetBuffer for comparison and write the populated segment directly through an unbuffered file stream. Preserve file sharing and Wave 18.14 behavior.

Co-authored-by: Copilot App <[email protected]>
Comment thread src/Tasks/AddToWin32Manifest.cs Resolved

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.

🟢 Approval recommended

No active review issues were identified for the change to avoid unnecessary manifest rewrites.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Comment thread src/Framework/ChangeWaves.cs Resolved
Comment thread src/Tasks/AddToWin32Manifest.cs Resolved
Comment thread src/Tasks/AddToWin32Manifest.cs Resolved
@JanProvaznik
JanProvaznik enabled auto-merge (squash) October 30, 2026 16:58
@JanProvaznik
JanProvaznik merged commit 49b51ed into dotnet:main Oct 30, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AddToWin32Manifest rewrites its manifest on every build, so a PreferNativeArm64 project never skips CoreCompile

4 participants