Skip to content

[net11.0] Exclude user assemblies from the Debug R2R input hash - #25893

Merged
rolfbjarne merged 4 commits into
net11.0from
dev/r2r-hash-exclude-user-assemblies
Jul 2, 2026
Merged

rolfbjarne merged 4 commits into
net11.0from
dev/r2r-hash-exclude-user-assemblies

Conversation

@kotlarmilos

@kotlarmilos kotlarmilos commented Jul 1, 2026 •

Copy link
Copy Markdown
Member

Description

User assemblies are passed to crossgen2 only as -r: references, which places them outside the composite version bubble, so crossgen2 reaches their types through runtime fixups rather than inlining or hardcoded layout. A change to a user assembly is resolved at load time and does not require recompiling the composite, so including them in the R2R input hash only forces crossgen2 to rerun on every user-code edit and defeats the Debug caching. This reverts the hash back to @(_NonUserAssemblies) only, matching how the .NET SDK's _CreateR2RImages incremental inputs already treat references.

Follow-up to #25879.

User assemblies are passed to crossgen2 only as -r: references, which places
them outside the composite version bubble, so crossgen2 reaches their types
through runtime fixups rather than inlining or hardcoded layout. A change to a
user assembly is resolved at load time and does not require recompiling the
composite, so including them in the R2R input hash only forces crossgen2 to
rerun on every user-code edit and defeats the Debug caching. This reverts the
hash back to @(_NonUserAssemblies) only, matching how the .NET SDK's
_CreateR2RImages incremental inputs already treat references.

Follow-up to #25879.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 1, 2026 08:17
@vs-mobiletools-engineering-service2

This comment has been minimized.

@kotlarmilos kotlarmilos self-assigned this Jul 1, 2026
@kotlarmilos kotlarmilos added this to the .NET 11 milestone Jul 1, 2026

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

This PR adjusts the Debug ReadyToRun (R2R) composite incremental hashing logic so that edits to user assemblies (which are only passed to crossgen2 as -r: references) no longer invalidate the cached composite and force crossgen2 to rerun on every user-code change. This aligns the hashing behavior with the intent of excluding user assemblies from the composite compilation bubble, as introduced in the follow-up to #25879.

Changes:

  • Update the R2R input hash to include only @(_NonUserAssemblies) (excluding @(_UserAssemblies)).
  • Refine the intent of the “touch outputs” optimization comment to reflect the new hashing behavior.
Show a summary per file
File Description
dotnet/targets/Microsoft.Sdk.R2R.targets Excludes user assemblies from the R2R input hash to improve Debug incremental caching behavior.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 2

@vitek-karas vitek-karas 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.

We should think about testing this - if there's a reasonable way to do so. Or do we rely on some perf measurements instead...

@vitek-karas

Copy link
Copy Markdown
Member

Side note: Would be interesting to know how the original problem can even happen. It would basically mean that some assembly which comes from NuGet/Framework has a reference to an assembly which doesn't in the given application.

This should never happen for Framework assemblies though - so maybe if we had a way to only recognize framework assemblies, that would be a better subset probably (avoiding these problems).

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

…compilation

Builds a Debug CoreCLR app twice; after a user-code-only change the test asserts
_TouchR2ROutputs runs and _CreateR2RImages is skipped, guarding that user
assemblies (passed to crossgen2 as references only) do not invalidate the cached
composite.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

kotlarmilos and others added 2 commits July 1, 2026 11:43
CoreCLR is already the net11.0 default (Xamarin.Shared.Sdk.props), so the
explicit property is unnecessary.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@kotlarmilos

Copy link
Copy Markdown
Member Author

We should think about testing this - if there's a reasonable way to do so. Or do we rely on some perf measurements instead...

Added a test for it IncrementalBuildTest.cs. It builds a Debug CoreCLR app, asserts _CreateR2RImages runs on the first build, then makes a user-code-only change and asserts on the rebuild that _TouchR2ROutputs runs and _CreateR2RImages  is skipped.

Side note: Would be interesting to know how the original problem can even happen. It would basically mean that some assembly which comes from NuGet/Framework has a reference to an assembly which doesn't in the given application.

This should never happen for Framework assemblies though - so maybe if we had a way to only recognize framework assemblies, that would be a better subset probably (avoiding these problems).

Right, it shouldn't happen for framework assemblies. The problem could be if there is a NuGet assembly which we classify as non-user assembly that has a MethodImpl whose declaring interface lives in an assembly we excluded. Narrowing the composite set to actual framework assemblies would avoid this class of problem.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@rolfbjarne

Copy link
Copy Markdown
Member

Side note: Would be interesting to know how the original problem can even happen. It would basically mean that some assembly which comes from NuGet/Framework has a reference to an assembly which doesn't in the given application.

Here's a verbose Copilot explanation of why this affected MAUI's build: https://gist.github.com/rolfbjarne/c6e631f1da214fd71b90eef4565e6961

TLDR: MAUI builds Microsoft.Maui.dll locally and also uses NuGets that reference Microsoft.Maui.dll.

Which doesn't sound all that far-fetched of a scenario for customers that produce libraries / NuGets.

This should never happen for Framework assemblies though - so maybe if we had a way to only recognize framework assemblies, that would be a better subset probably (avoiding these problems).

We already do something like this in a number of places:

'%(ResolvedFileToPublish.NuGetPackageId)' == 'Microsoft.NETCore.App.Runtime.$(RuntimeIdentifier)'

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [PR Build #dc6d550] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: dc6d55088a94649c28e215b2b159384fa0e4787f [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [PR Build #dc6d550] Build passed (Build packages) ✅

Pipeline on Agent
Hash: dc6d55088a94649c28e215b2b159384fa0e4787f [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [CI Build #5cc77af] Prepare .NET Release succeeded ✅

📦 Published NuGet packages (32 packages)

iOS

  • Microsoft.iOS.Ref.net11.0_26.5.26.5.11793-net11-p7.nupkg
  • Microsoft.iOS.Runtime.ios-arm64.net11.0_26.5.26.5.11793-net11-p7.nupkg
  • Microsoft.iOS.Runtime.ios.net11.0_26.5.26.5.11793-net11-p7.nupkg
  • Microsoft.iOS.Runtime.iossimulator-arm64.net11.0_26.5.26.5.11793-net11-p7.nupkg
  • Microsoft.iOS.Runtime.iossimulator-x64.net11.0_26.5.26.5.11793-net11-p7.nupkg
  • Microsoft.iOS.Sdk.net11.0_26.5.26.5.11793-net11-p7.nupkg
  • Microsoft.iOS.Templates.26.5.11793-net11-p7.nupkg
  • Microsoft.iOS.Windows.Sdk.net11.0_26.5.26.5.11793-net11-p7.nupkg
  • Microsoft.NET.Sdk.iOS.Manifest-11.0.100-preview.6.26.5.11793-net11-p7.nupkg

MacCatalyst

  • Microsoft.MacCatalyst.Ref.net11.0_26.5.26.5.11793-net11-p7.nupkg
  • Microsoft.MacCatalyst.Runtime.maccatalyst-arm64.net11.0_26.5.26.5.11793-net11-p7.nupkg
  • Microsoft.MacCatalyst.Runtime.maccatalyst-x64.net11.0_26.5.26.5.11793-net11-p7.nupkg
  • Microsoft.MacCatalyst.Runtime.maccatalyst.net11.0_26.5.26.5.11793-net11-p7.nupkg
  • Microsoft.MacCatalyst.Sdk.net11.0_26.5.26.5.11793-net11-p7.nupkg
  • Microsoft.MacCatalyst.Templates.26.5.11793-net11-p7.nupkg
  • Microsoft.NET.Sdk.MacCatalyst.Manifest-11.0.100-preview.6.26.5.11793-net11-p7.nupkg

macOS

  • Microsoft.macOS.Ref.net11.0_26.5.26.5.11793-net11-p7.nupkg
  • Microsoft.macOS.Runtime.osx-arm64.net11.0_26.5.26.5.11793-net11-p7.nupkg
  • Microsoft.macOS.Runtime.osx-x64.net11.0_26.5.26.5.11793-net11-p7.nupkg
  • Microsoft.macOS.Runtime.osx.net11.0_26.5.26.5.11793-net11-p7.nupkg
  • Microsoft.macOS.Sdk.net11.0_26.5.26.5.11793-net11-p7.nupkg
  • Microsoft.macOS.Templates.26.5.11793-net11-p7.nupkg
  • Microsoft.NET.Sdk.macOS.Manifest-11.0.100-preview.6.26.5.11793-net11-p7.nupkg

tvOS

  • Microsoft.NET.Sdk.tvOS.Manifest-11.0.100-preview.6.26.5.11793-net11-p7.nupkg
  • Microsoft.tvOS.Ref.net11.0_26.5.26.5.11793-net11-p7.nupkg
  • Microsoft.tvOS.Runtime.tvos-arm64.net11.0_26.5.26.5.11793-net11-p7.nupkg
  • Microsoft.tvOS.Runtime.tvos.net11.0_26.5.26.5.11793-net11-p7.nupkg
  • Microsoft.tvOS.Runtime.tvossimulator-arm64.net11.0_26.5.26.5.11793-net11-p7.nupkg
  • Microsoft.tvOS.Runtime.tvossimulator-x64.net11.0_26.5.26.5.11793-net11-p7.nupkg
  • Microsoft.tvOS.Sdk.net11.0_26.5.26.5.11793-net11-p7.nupkg
  • Microsoft.tvOS.Templates.26.5.11793-net11-p7.nupkg

Other

  • Sharpie.Bind.Tool.26.6.0.397-net11-p7.nupkg

Pipeline on Agent
Hash: 5cc77af5839ea684f20f5e9c9d493707fcf0ef36 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [PR Build #dc6d550] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: dc6d55088a94649c28e215b2b159384fa0e4787f [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: dc6d55088a94649c28e215b2b159384fa0e4787f [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🚀 [CI Build #dc6d550] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 208 tests passed 🎉

Tests counts

✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download
✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
✅ linker (iOS): All 21 tests passed. Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 21 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 21 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 21 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 18 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 18 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 18 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 18 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

macOS tests

✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sequoia (15): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Tahoe (26): All 5 tests passed. [attempt 3] Html Report (VSDrops) Download

Linux Build Verification

✅ Linux build succeeded

Pipeline on Agent
Hash: dc6d55088a94649c28e215b2b159384fa0e4787f [PR build]

@rolfbjarne
rolfbjarne merged commit 200c07c into net11.0 Jul 2, 2026
54 checks passed
@rolfbjarne
rolfbjarne deleted the dev/r2r-hash-exclude-user-assemblies branch July 2, 2026 05:37
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.

5 participants