Skip to content

MSB4096 with user-defined TrimmerRootAssembly #10758

Closed

Description

@sbomer

Summary

The _FixRootAssembly target in Microsoft.Android.Sdk.ILLink.targets uses %(RootMode) without fully qualifying it as %(TrimmerRootAssembly.RootMode). This causes MSB4096 when user-defined TrimmerRootAssembly items don't have the RootMode metadata.

Repro

Create a MAUI app with TrimmerRootAssembly items that don't specify RootMode:

<ItemGroup>
  <TrimmerRootAssembly Include="Microsoft.Maui" />
  <TrimmerRootAssembly Include="Microsoft.Maui.Controls" />
</ItemGroup>

Error

error MSB4096: The item "Microsoft.Maui" in item list "TrimmerRootAssembly" does not define a value for metadata "RootMode". In order to use this metadata, either qualify it by specifying %(TrimmerRootAssembly.RootMode), or ensure that all items in this list define a value for this metadata.

In Microsoft.Android.Sdk.ILLink.targets:

<Target Name="_FixRootAssembly" AfterTargets="PrepareForILLink">
  <ItemGroup>
    <TrimmerRootAssembly Update="@(TrimmerRootAssembly)" Condition=" '%(RootMode)' == 'EntryPoint' " RootMode="All" />
  </ItemGroup>
</Target>

The condition uses %(RootMode) which triggers MSBuild item batching. When batching, MSBuild requires all items to have the metadata defined.

Related: dotnet/runtime#123972 (comment)
Discovered in dotnet/maui#33756

Activity

  1. added
    needs-triage
    on Feb 3, 2026
  2. locked and limited conversation to collaborators on Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

needs-triage

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions