Skip to content

[NativeAOT] Exclude extracted BundleResource data. Fixes #27560 - #27611

Open
rolfbjarne wants to merge 10 commits into
mainfrom
dev/rolf/nativeaot-bundle-resources
Open

rolfbjarne wants to merge 10 commits into
mainfrom
dev/rolf/nativeaot-bundle-resources

Conversation

@rolfbjarne

@rolfbjarne rolfbjarne commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 6df7bf28736df99a986fd695c0ad4ef8897b2240

Dimension Assessment Rationale
Change confidence 9/10 ↑ Both resource-packaging modes passed single-RID and universal macOS checks, including cache regeneration and no-op builds.
↑ Tests cover distinct compile and runtime modules and renamed files.
↓ iOS integration remains unrun.
Diagnosis confidence 9/10 ↑ Integration verifies extracted resource bytes are absent from the executable.
↑ Exclusions match the extracted resource's module ID and name.
Evidence fit 9/10 ↑ The reported symptom is directly covered by the regression check.
↓ 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

rolfbjarne and others added 5 commits December 3, 2026 12:28
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>
@rolfbjarne
rolfbjarne requested a review from dalexsoto as a code owner December 3, 2026 11:47
Copilot AI balanced review requested due to automatic review settings December 3, 2026 11:47

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.

🟡 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

@rolfbjarne

Copy link
Copy Markdown
Member Author

@dalexsoto review

@dalexsoto

Copy link
Copy Markdown
Member

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.

@MauiBot

MauiBot commented Dec 3, 2026

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: fd974b967fa0a25202926665d54e6c0868bf04df [PR build]

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

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.

@MauiBot

MauiBot commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

🔥 [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
✅ 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 1 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 12 tests passed. Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 12 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 12 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 12 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 11 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 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. Html Report (VSDrops) Download
✅ Tests on macOS Golden Gate (27): All 5 tests passed. Html Report (VSDrops) Download

Linux Build Verification

✅ Linux build succeeded

Pipeline on Agent
Hash: fd974b967fa0a25202926665d54e6c0868bf04df [PR build]

rolfbjarne and others added 2 commits December 3, 2026 16:33
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings December 3, 2026 15:58
@rolfbjarne

Copy link
Copy Markdown
Member Author

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

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.

🟡 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

Comment thread tests/dotnet/UnitTests/ProjectTest.cs Resolved
dalexsoto
dalexsoto previously approved these changes Dec 3, 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.

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.

@MauiBot

MauiBot commented Dec 3, 2026

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: f63698b9304108bd5455f41bd117ad976631fabe [PR build]

@MauiBot

MauiBot commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

🚀 [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
✅ 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 1 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 12 tests passed. Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 12 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 12 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 12 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 11 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 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

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. Html Report (VSDrops) Download
✅ Tests on macOS Golden Gate (27): All 5 tests passed. Html Report (VSDrops) Download

Linux Build Verification

✅ Linux build succeeded

Pipeline on Agent
Hash: f63698b9304108bd5455f41bd117ad976631fabe [PR build]

@rolfbjarne rolfbjarne added the backport-to-net11.0 Add this to issues or pull requests that should be backported to .NET 11 label Dec 4, 2026
Comment thread tools/mtouch/Errors.resx Resolved
rolfbjarne and others added 3 commits December 4, 2026 11:25
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>
Copilot AI balanced review requested due to automatic review settings December 4, 2026 10:49

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.

🟢 Approval recommended

No active review issues remain for the NativeAOT resource-exclusion changes.

No open issues 🎉

1 resolved since last review
1 file not reviewed
  • tools/mtouch/Errors.designer.cs: Generated file

Review effort: Balanced

@MauiBot

MauiBot commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator

🔥 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
Hash: [PR build]

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

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.

@MauiBot

MauiBot commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator

🔥 [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) tests

⚠️ Tests did not run because the Build macOS tests job failed.

Html Report (VSDrops) Download

❌ Tests on macOS Sequoia (15) tests

⚠️ Tests did not run because the Build macOS tests job failed.

Html Report (VSDrops) Download

❌ Tests on macOS Tahoe (26) tests

⚠️ Tests did not run because the Build macOS tests job failed.

Html Report (VSDrops) Download

❌ Tests on macOS Golden Gate (27) tests

⚠️ Tests did not run because the Build macOS tests job failed.

Html Report (VSDrops) Download

Successes

macOS tests

Linux Build Verification

✅ Linux build succeeded

Pipeline on Agent
Hash: 6df7bf28736df99a986fd695c0ad4ef8897b2240 [PR build]

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-to-net11.0 Add this to issues or pull requests that should be backported to .NET 11 copilot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[NativeAOT] Remove extracted BundleResource data from the executable

4 participants