Repository navigation
[net11.0] Exclude user assemblies from the Debug R2R input hash - #25893
Conversation
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>
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
We should think about testing this - if there's a reasonable way to do so. Or do we rely on some perf measurements instead...
|
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). |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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>
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.
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. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
We already do something like this in a number of places:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #dc6d550] Build passed (Build macOS tests) ✅Pipeline on Agent |
✅ [PR Build #dc6d550] Build passed (Build packages) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ [CI Build #5cc77af] Prepare .NET Release succeeded ✅📦 Published NuGet packages (32 packages)iOS
MacCatalyst
macOS
tvOS
Other
Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #dc6d550] Build passed (Detect API changes) ✅Pipeline on Agent |
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
🚀 [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 macOS tests✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
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_CreateR2RImagesincremental inputs already treat references.Follow-up to #25879.