Skip to content

[net11.0] Cache R2R image when only user assemblies are changed#24735

Open
kotlarmilos wants to merge 3 commits intonet11.0from
dev/cache-r2r-image
Open

[net11.0] Cache R2R image when only user assemblies are changed#24735
kotlarmilos wants to merge 3 commits intonet11.0from
dev/cache-r2r-image

Conversation

@kotlarmilos
Copy link
Member

@kotlarmilos kotlarmilos commented Feb 18, 2026

Desription

In non-Release R2R composite mode when user assemblies change, they are treated as entry points and used as inputs to the _CreateR2RImages target. As a result the ILLink task always writes new assemblies to disk, which forces the _CreateR2RImages task to execute every time.

The caching mechanism works by computing a content-based hash of non-user assemblies, then writing this hash to an intermediate file. A .trigger file is touched on every build to track when the hash was last computed. If the hash file is older than the trigger file (meaning the hash didn't change), the R2R outputs are touched to satisfy msbuild incremental build checks, skipping the R2R compilation step.

With this change, incremental build time for user assembly changes is reduced from ~39s to ~26s.

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

Comment on lines 1418 to 1421
<WriteLinesToFile
File="$(_TrimHashesFile)"
Lines="@(_TrimmedDllsWithHash->'%(Identity)|%(FileHash)')"
Overwrite="true" />
Copy link
Member

Choose a reason for hiding this comment

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

There might be a simpler way to implement this:

  1. After selecting which assemblies to add to the R2R image (say in the _SelectR2RAssemblies target), compute the hash contents
  2. Write these hash contents to the hash file with the WriteLinesToFile task, but also set the WriteOnlyWhenDifferent="true" property on the task.
  3. Use the timestamp of the hash file to determine whether R2R needs to run or not. One (somewhat hacky) way of doing this would be to set the timestamp of all the R2R assemblies to the timestamp of the hash file.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, updated. One thing - touching the input doesn’t scale well (it took ~4s for the MAUI template), so I introduced a .trigger file that is always updated. It checks whether the hash has been written and if it has, it touch the output instead.

@kotlarmilos kotlarmilos marked this pull request as ready for review February 19, 2026 12:47
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #93c4b82] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 93c4b82b8dae6f18f60d1c8a022f00e4628754d3 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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

Pipeline on Agent
Hash: 93c4b82b8dae6f18f60d1c8a022f00e4628754d3 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
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: 93c4b82b8dae6f18f60d1c8a022f00e4628754d3 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #93c4b82] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 93c4b82b8dae6f18f60d1c8a022f00e4628754d3 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #93c4b82] Tests on macOS X64 - Mac Sonoma (14) passed 💻

All tests on macOS X64 - Mac Sonoma (14) passed.

Pipeline on Agent
Hash: 93c4b82b8dae6f18f60d1c8a022f00e4628754d3 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #93c4b82] Tests on macOS arm64 - Mac Sequoia (15) passed 💻

All tests on macOS arm64 - Mac Sequoia (15) passed.

Pipeline on Agent
Hash: 93c4b82b8dae6f18f60d1c8a022f00e4628754d3 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #93c4b82] Tests on macOS arm64 - Mac Tahoe (26) passed 💻

All tests on macOS arm64 - Mac Tahoe (26) passed.

Pipeline on Agent
Hash: 93c4b82b8dae6f18f60d1c8a022f00e4628754d3 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🚀 [CI Build #93c4b82] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 117 tests passed 🎉

Tests counts

✅ 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. 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: All 44 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 9 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 9 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 9 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. 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

Pipeline on Agent
Hash: 93c4b82b8dae6f18f60d1c8a022f00e4628754d3 [PR build]

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.

3 participants

Comments