Repository navigation
[NativeAOT] Exclude extracted BundleResource data. Fixes #27560 - #27611
rolfbjarne wants to merge 10 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Resource-owner lookup uses DLL filenames rather than managed assembly identities, so renamed or case-mismatched references can leave extracted resources embedded.
2 open issues
What changed in this PR
Addresses #27560 by excluding extracted library bundle resources from NativeAOT executables while preserving ordinary managed resources and app-owned assets.
Changes:
- Tracks extracted resources and generates assembly-specific exclusions.
- Shares extraction caches across universal builds and tracks preparation inputs.
- Adds regression coverage and updates NativeAOT documentation.
| File | Description |
|---|---|
| tools/assembly-preparer/GenerateNativeAOTResourceSubstitutionsStep.cs | Excludes recorded resources on device and desktop builds. |
| tools/assembly-preparer/AssemblyPreparer.cs | Stores and serializes resource exclusions. |
| tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/UnpackLibraryResourcesTests.cs | Checks extraction metadata and cached resources. |
| tests/linker/link all/dotnet/shared.csproj | Includes the test AppDelegate on macOS. |
| tests/dotnet/UnitTests/ProjectTest.cs | Tests resource exclusions and incremental builds. |
| tests/dotnet/UnitTests/AssetsTest.cs | Exposes the asset-inspection helper. |
| tests/dotnet/LibraryWithResources/shared.csproj | Adds an optional managed control resource. |
| tests/dotnet/LibraryWithResources/ResourceControl.txt | Supplies preservation-test data. |
| tests/dotnet/LibraryWithResources/AppDelegate.cs | Adds a library reference marker. |
| tests/dotnet/AppWithLibraryWithResourcesReference/AppDelegate.cs | Keeps the library referenced. |
| tests/assembly-preparer/ReproTest.cs | Tests exclusion configuration round-tripping. |
| tests/assembly-preparer/GenerateNativeAOTResourceSubstitutionsStepTests.cs | Tests resource ownership and simulator behavior. |
| msbuild/Xamarin.Shared/Xamarin.Shared.targets | Caches extraction records and passes preparation inputs. |
| msbuild/Xamarin.MacDev.Tasks/Tasks/UnpackLibraryResources.cs | Records all extracted resources and embedded names. |
| msbuild/Xamarin.MacDev.Tasks/Tasks/PrepareAssemblies.cs | Passes resource exclusions to assembly preparation. |
| dotnet/targets/Xamarin.Shared.Sdk.targets | Shares caches and loads resources before preparation. |
| docs/nativeaot.md | Documents bundle-resource exclusions. |
Review effort: Balanced
|
@dalexsoto review |
|
In response to @rolfbjarne's request: The NativeAOT resource review is continuing on head fd974b9. I still need to verify the extraction/preparation wiring in Xamarin.Shared.targets and Xamarin.Shared.Sdk.targets, incremental/cache behavior, and the changed resource tests and docs after tracing the core resource-handling code. These are gaps in my review coverage, not defects found in the PR; no GitHub/API failure occurred. I am carrying that exact scope into the next scheduled review pass rather than submitting an unsupported verdict. |
✅ 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 |
dalexsoto
left a comment
There was a problem hiding this comment.
Blocking: NativeAOT can remove a resource from a different DLL than the one unpacked.
PrepareAssemblies.cs:89 and GenerateNativeAOTResourceSubstitutionsStep.cs:41 identify extracted resources only by simple assembly name and resource name. However, extraction uses ReferencePath/ReferenceDependencyPaths (Xamarin.Shared.targets:2284), while preparation uses ResolvedFileToPublish (line 3810). A package can provide distinct compile and RID-specific runtime Foo.dll assets with the same assembly/resource names but different bytes. This extracts the compile asset payload, then strips the runtime asset resource; the runtime payload was preserved at the merge base. This does not require either DLL to be renamed and is distinct from the existing filename/metadata-name concern.
Carry the originating module identity from extraction and emit exclusions only for resources extracted from that same module. Please add a regression with distinct compile/runtime DLLs sharing the assembly and manifest-resource names.
Review-completeness correction: the earlier static pass missed this case. The separate final pass over all 17 changed files and material integration paths found no additional high-confidence blockers. Static review only; no builds or tests were run.
🔥 [CI Build #fd974b9] Test results 🔥Test results❌ Tests failed on VSTS: test results 1 tests crashed, 0 tests failed, 142 tests passed. Failures❌ windows tests🔥 Failed catastrophically on VSTS: test results - windows (no summary found). Html Report (VSDrops) Download Successes✅ 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 |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
@dalexsoto Resource exclusions now use the extracted module’s MVID and resource name, so a separate runtime module with the same assembly and resource names is preserved. The regression test uses distinct compile and runtime DLLs with different payloads, and also checks extraction through a renamed path. Note Copilot-generated. |
There was a problem hiding this comment.
🟡 Changes recommended
The NativeAOT integration tests cover only compiled-resource packaging, leaving the default BundleOriginalResources=true path and preservation of library-owned compiled assets unverified.
1 open issue
2 resolved since last review
1 file not reviewed
tools/mtouch/Errors.designer.cs: Generated file
Review effort: Balanced
dalexsoto
left a comment
There was a problem hiding this comment.
The module-MVID/resource-name matching fixes the compile-time versus runtime assembly resource-ownership issue from my earlier review. I also reviewed the extraction/cache flow, pre-trim NativeAOT substitutions, regression-test changes, error-resource wiring, and current target-branch interactions; no remaining blocking issues found.
✅ 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 |
🚀 [CI Build #f63698b] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 145 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 |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
🔥 Unable to find the contents for the comment: D:\a\1\s\change-detection\results\gh-comment.md does not exist :fire Pipeline on Agent |
dalexsoto
left a comment
There was a problem hiding this comment.
Reviewed the current NativeAOT resource-exclusion changes, including module/resource identity matching, incremental cache regeneration, both resource-packaging modes and the MX0187 diagnostic update. The earlier blockers are addressed; no additional blocking issues found in static review.
🔥 [CI Build #6df7bf2] Test results 🔥Test results❌ Tests failed on VSTS: test results 29 tests crashed, 0 tests failed, 0 tests passed. Failures❌ assembly-processing tests🔥 Failed catastrophically on VSTS: test results - assembly-processing (no summary found). Html Report (VSDrops) Download ❌ cecil tests🔥 Failed catastrophically on VSTS: test results - cecil (no summary found). Html Report (VSDrops) Download ❌ dotnettests tests (iOS)🔥 Failed catastrophically on VSTS: test results - dotnettests_ios (no summary found). Html Report (VSDrops) Download ❌ dotnettests tests (MacCatalyst)🔥 Failed catastrophically on VSTS: test results - dotnettests_maccatalyst (no summary found). Html Report (VSDrops) Download ❌ dotnettests tests (macOS)🔥 Failed catastrophically on VSTS: test results - dotnettests_macos (no summary found). Html Report (VSDrops) Download ❌ dotnettests tests (Multiple platforms)🔥 Failed catastrophically on VSTS: test results - dotnettests_multiple (no summary found). Html Report (VSDrops) Download ❌ dotnettests tests (tvOS)🔥 Failed catastrophically on VSTS: test results - dotnettests_tvos (no summary found). Html Report (VSDrops) Download ❌ framework tests🔥 Failed catastrophically on VSTS: test results - framework (no summary found). Html Report (VSDrops) Download ❌ fsharp tests🔥 Failed catastrophically on VSTS: test results - fsharp (no summary found). Html Report (VSDrops) Download ❌ generator tests🔥 Failed catastrophically on VSTS: test results - generator (no summary found). Html Report (VSDrops) Download ❌ interdependent-binding-projects tests🔥 Failed catastrophically on VSTS: test results - interdependent-binding-projects (no summary found). Html Report (VSDrops) Download ❌ introspection tests🔥 Failed catastrophically on VSTS: test results - introspection (no summary found). Html Report (VSDrops) Download ❌ linker tests (iOS)🔥 Failed catastrophically on VSTS: test results - linker_ios (no summary found). Html Report (VSDrops) Download ❌ linker tests (MacCatalyst)🔥 Failed catastrophically on VSTS: test results - linker_maccatalyst (no summary found). Html Report (VSDrops) Download ❌ linker tests (macOS)🔥 Failed catastrophically on VSTS: test results - linker_macos (no summary found). Html Report (VSDrops) Download ❌ linker tests (tvOS)🔥 Failed catastrophically on VSTS: test results - linker_tvos (no summary found). Html Report (VSDrops) Download ❌ monotouch tests (iOS)🔥 Failed catastrophically on VSTS: test results - monotouch_ios (no summary found). Html Report (VSDrops) Download ❌ monotouch tests (MacCatalyst)🔥 Failed catastrophically on VSTS: test results - monotouch_maccatalyst (no summary found). Html Report (VSDrops) Download ❌ monotouch tests (macOS)🔥 Failed catastrophically on VSTS: test results - monotouch_macos (no summary found). Html Report (VSDrops) Download ❌ monotouch tests (tvOS)🔥 Failed catastrophically on VSTS: test results - monotouch_tvos (no summary found). Html Report (VSDrops) Download ❌ msbuild tests🔥 Failed catastrophically on VSTS: test results - msbuild (no summary found). Html Report (VSDrops) Download ❌ sharpie tests🔥 Failed catastrophically on VSTS: test results - sharpie (no summary found). Html Report (VSDrops) Download ❌ windows tests🔥 Failed catastrophically on VSTS: test results - windows (no summary found). Html Report (VSDrops) Download ❌ xcframework tests🔥 Failed catastrophically on VSTS: test results - xcframework (no summary found). Html Report (VSDrops) Download ❌ xtro tests🔥 Failed catastrophically on VSTS: test results - xtro (no summary found). Html Report (VSDrops) Download ❌ Tests on macOS Sonoma (14) testsHtml Report (VSDrops) Download ❌ Tests on macOS Sequoia (15) testsHtml Report (VSDrops) Download ❌ Tests on macOS Tahoe (26) testsHtml Report (VSDrops) Download ❌ Tests on macOS Golden Gate (27) testsHtml Report (VSDrops) Download SuccessesmacOS testsLinux Build VerificationPipeline on Agent |



Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
6df7bf28736df99a986fd695c0ad4ef8897b2240↑ Tests cover distinct compile and runtime modules and renamed files.
↓ iOS integration remains unrun.
↑ Exclusions match the extracted resource's module ID and name.
↓ The issue's exact sample project and Xcode setup were not run.
This change records resources extracted from referenced libraries and excludes only those resources from NativeAOT output, while preserving app-owned assets and ordinary managed resources. It also keeps the extracted-resource cache separate from per-assembly item files and makes universal-build cache regeneration incremental.
Fixes #27560
Note
Copilot-generated.
🤖 Pull request created by Copilot