Repository navigation
Fix MSB4096 error with user-defined TrimmerRootAssembly items lacking RootMode metadata - #10759
Merged
Merged
Conversation
Change %(RootMode) to %(TrimmerRootAssembly.RootMode) in _FixRootAssembly target to avoid requiring all TrimmerRootAssembly items to have RootMode metadata. Add test case to verify the fix. Co-authored-by: sbomer <[email protected]>
- Remove placeholder issue number from comment - Remove trailing whitespace Co-authored-by: sbomer <[email protected]>
Copilot
AI
changed the title
[WIP] Fix MSB4096 error with user-defined TrimmerRootAssembly
Fix MSB4096 error with user-defined TrimmerRootAssembly items lacking RootMode metadata
Feb 3, 2026
jonathanpeppers
marked this pull request as ready for review
February 4, 2026 15:06
jonathanpeppers
requested review from
grendello and
simonrozsival
as code owners
February 4, 2026 15:06
jonathanpeppers
approved these changes
Feb 4, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes an MSB4096 error that occurs when users add TrimmerRootAssembly items without the RootMode metadata. The issue was caused by an unqualified metadata reference in the _FixRootAssembly target, which triggered MSBuild item batching that requires all items to have the metadata defined.
Changes:
- Qualified the metadata reference from
%(RootMode)to%(TrimmerRootAssembly.RootMode)in the condition - Added a test case to verify that user-defined
TrimmerRootAssemblyitems withoutRootModemetadata work correctly
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.ILLink.targets | Fixed metadata reference in _FixRootAssembly target to use qualified form, preventing MSB4096 batching error |
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs | Added test to verify user-defined TrimmerRootAssembly items without RootMode metadata don't cause build failures |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

The
_FixRootAssemblytarget fails with MSB4096 when users addTrimmerRootAssemblyitems withoutRootModemetadata. The unqualified%(RootMode)reference triggers MSBuild item batching, which requires all items to define the metadata.Changes
%(TrimmerRootAssembly.RootMode)RootModeare now skipped (condition evaluates to'' == 'EntryPoint') instead of causing batching errorsUser projects can now safely add trimmer root assemblies without metadata:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.