Skip to content

[release/11.0.1xx] Fix PE timestamp for deterministic resource designer assemblies - #13158

Merged
jonathanpeppers merged 3 commits into
release/11.0.1xxfrom
backport/pr-13144-to-release/11.0.1xx
Nov 10, 2026
Merged

jonathanpeppers merged 3 commits into
release/11.0.1xxfrom
backport/pr-13144-to-release/11.0.1xx

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Backport of #13144 to release/11.0.1xx

/cc @jonathanpeppers @copilot

Cecil’s wall-clock PE timestamp changes `_Microsoft.Android.Resource.Designer.dll` between identical builds, even with `Deterministic=true`. The timestamp also changes the content-derived MVID, cascading differences into application assemblies and downstream native artifacts.

- **Generation:** Set `WriterParameters.Timestamp` to zero for deterministic output; retain Cecil’s default timestamp otherwise.
  ```csharp
  DeterministicMvid = Deterministic,
  Timestamp = Deterministic ? 0u : null,
  ```
- **Regression coverage:** Cover application and library designers in both modes, checking deterministic byte equality and matching MVIDs, plus preservation of non-deterministic timestamp and MVID behavior.

<!-- START COPILOT CODING AGENT SUFFIX -->

- Fixes #13140

@jonathanpeppers jonathanpeppers left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The timestamp fix appears to expose an existing incremental-build bug, rather than produce an invalid assembly.

Both failed attempts in [build 1637020](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1637020) hit:

Runtime critical type System.Diagnostics.MonoStackFrame not found

The third attempt is still running, but its Mono build has already failed with the same error.

Using binlogtool, I traced this sequence:

  1. Release builds with CoreCLR and runs the linker.

  2. The lane builds the same project and intermediate directories with UseMonoRuntime=true.

  3. Designer generation reports _Microsoft.Android.Resource.Designer.dll “was up to date.”

  4. _RunILLink incorrectly skips both arm64 and x64, reusing the CoreCLR-linked outputs.

  5. Mono AOT then fails across multiple assemblies—not just the resource designer—because it expects Mono’s System.Diagnostics.MonoStackFrame.

The likely connection is that the old PE timestamp changed the designer’s bytes, incidentally forcing relinking. Making those bytes deterministic removes that accidental invalidation.

The fix should be to invalidate linked outputs when switching runtimes. Cleaning between the CoreCLR and Mono builds, or giving them separate intermediate directories, would avoid the lane failure. The error also matches the CoreCLR/Mono AOT mismatch described in [#11241](#11241). Another unchanged retry is unlikely to help.

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

Copilot-Session: 109f55a1-56cd-4551-8f90-4c1704c22f4f
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 109f55a1-56cd-4551-8f90-4c1704c22f4f
jonathanpeppers added a commit that referenced this pull request Oct 21, 2026
Port the linker-cache fix from #13158 to main.

When Android build properties change, `build.props` changes, but `_RunILLink` does not track it. On the release branch, switching from CoreCLR to Mono can therefore reuse incompatible linked assemblies and fail Mono AOT with `Runtime critical type System.Diagnostics.MonoStackFrame not found`.

Add the Android-owned `_AndroidInvalidateLinkerCache` target from commit 3dd8d4e. Before linking, it deletes each RID's semaphore if `build.props` is newer. Unchanged builds still skip linking. No changes to `MSBuildAllProjects`. Main already has the runtime cache entries and the timestamp fix from #13144.

Extend `PostTrimmingPipelineIsSkippedOnSecondBuild` in `IncrementalBuildTest.cs` to check cached property changes and subsequent unchanged builds for arm64 and x64. No new test file or test helpers.

Co-authored-by: Copilot App <[email protected]>
@jonathanpeppers jonathanpeppers added the do-not-merge PR should not be merged. label Oct 22, 2026
@jonathanpeppers jonathanpeppers removed the do-not-merge PR should not be merged. label Nov 10, 2026
@jonathanpeppers
jonathanpeppers dismissed their stale review November 10, 2026 19:31

Branch is open now

@jonathanpeppers
jonathanpeppers enabled auto-merge (squash) November 10, 2026 19:32
@jonathanpeppers

Copy link
Copy Markdown
Member

@dalexsoto review

@jonathanpeppers jonathanpeppers added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Nov 10, 2026

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Backport is byte-identical to #13144 for the PE-timestamp fix and test, plus the _AndroidRuntime cache entry and _AndroidInvalidateLinkerCache target matching main; release-branch targets exist and all 44 CI checks passed. No blocking issues found. Static read only; nothing was built or run.

@jonathanpeppers
jonathanpeppers merged commit 7bfcece into release/11.0.1xx Nov 10, 2026
44 checks passed
@jonathanpeppers
jonathanpeppers deleted the backport/pr-13144-to-release/11.0.1xx branch November 10, 2026 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants