Skip to content

Simplify TrimmerSingleWarn intermediate assembly update using MSBuild item Update#125630

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-feedback-implementation
Draft

Simplify TrimmerSingleWarn intermediate assembly update using MSBuild item Update#125630
Copilot wants to merge 3 commits intomainfrom
copilot/fix-feedback-implementation

Conversation

Copy link
Contributor

Copilot AI commented Mar 16, 2026

Description

Follow-up to PR #124801 review feedback: the "intersection via include/remove, then remove+re-include" pattern in _PrepareTrimConfiguration was complex, mutated item ordering, and used two throwaway item groups. Replace with a direct MSBuild Update.

Change

Before — compute intersection manually to set metadata, then remove+re-add items:

<__SingleWarnIntermediateAssembly Include="@(ResolvedFileToPublish)" />
<__SingleWarnIntermediateAssembly Remove="@(IntermediateAssembly)" />
<_SingleWarnIntermediateAssembly Include="@(ResolvedFileToPublish)" />
<_SingleWarnIntermediateAssembly Remove="@(__SingleWarnIntermediateAssembly)" />
<_SingleWarnIntermediateAssembly>
  <TrimmerSingleWarn Condition="...">false</TrimmerSingleWarn>
</_SingleWarnIntermediateAssembly>
<ResolvedFileToPublish Remove="@(_SingleWarnIntermediateAssembly)" />
<ResolvedFileToPublish Include="@(_SingleWarnIntermediateAssembly)" />

After — update matching items directly, preserving order:

<ResolvedFileToPublish Update="@(IntermediateAssembly)">
  <TrimmerSingleWarn Condition=" '%(ResolvedFileToPublish.TrimmerSingleWarn)' == '' ">false</TrimmerSingleWarn>
</ResolvedFileToPublish>

Changes proposed in this pull request

  • [Microsoft.NET.ILLink.targets] Replace 13-line intersection pattern with a 3-line Update in _PrepareTrimConfiguration
  • [Microsoft.NET.ILLink.targets] Qualify %(TrimmerSingleWarn) as %(ResolvedFileToPublish.TrimmerSingleWarn) in the Update condition to prevent MSB4096 (unqualified metadata batching over all ResolvedFileToPublish items, including those without the metadata defined)

Additional context


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI and others added 2 commits March 16, 2026 18:38
…pdate approach

Co-authored-by: sbomer <787361+sbomer@users.noreply.github.com>
@dotnet-policy-service dotnet-policy-service bot added the linkable-framework Issues associated with delivering a linker friendly framework label Mar 16, 2026
@github-actions github-actions bot added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Mar 16, 2026
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @agocke, @dotnet/illink
See info in area-owners.md if you want to be subscribed.

@sbomer
Copy link
Member

sbomer commented Mar 16, 2026

@copilot fix this error:

##[error]src/tools/illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets(227,5): error MSB4096: (NETCORE_ENGINEERING_TELEMETRY=Build) The item "/__w/1/s/artifacts/obj/coreclr/ILCompiler_inbuild/linux.x64.Release/singlefilehost" in item list "ResolvedFileToPublish" does not define a value for metadata "TrimmerSingleWarn".  In order to use this metadata, either qualify it by specifying %(ResolvedFileToPublish.TrimmerSingleWarn), or ensure that all items in this list define a value for this metadata.

…ondition

Co-authored-by: sbomer <787361+sbomer@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 16, 2026

@copilot fix this error:

##[error]src/tools/illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets(227,5): error MSB4096: (NETCORE_ENGINEERING_TELEMETRY=Build) The item "/__w/1/s/artifacts/o...

Fixed in 1cb9ce2. The unqualified %(TrimmerSingleWarn) in the Condition was triggering MSBuild to batch over all ResolvedFileToPublish items (not just those being updated), causing MSB4096 for items without that metadata. Changed to %(ResolvedFileToPublish.TrimmerSingleWarn) to qualify it properly.

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

Labels

area-Tools-ILLink .NET linker development as well as trimming analyzers linkable-framework Issues associated with delivering a linker friendly framework

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants