Skip to content

Add --strip-il-bodies crossgen2 arg for Apple mobile RIDs#54143

Open
kotlarmilos wants to merge 1 commit intodotnet:mainfrom
kotlarmilos:fix-r2r-strip-il-bodies-msb4099
Open

Add --strip-il-bodies crossgen2 arg for Apple mobile RIDs#54143
kotlarmilos wants to merge 1 commit intodotnet:mainfrom
kotlarmilos:fix-r2r-strip-il-bodies-msb4099

Conversation

@kotlarmilos
Copy link
Copy Markdown
Member

@kotlarmilos kotlarmilos commented Apr 29, 2026

Description

Mirror the changes from dotnet/runtime#125647.

For Apple mobile RIDs (ios-, tvos-, iossimulator-, tvossimulator-, maccatalyst-), pass --strip-il-bodies to crossgen2 by default via PublishReadyToRunCrossgen2CompositeExtraArgs when composite R2R is enabled (PublishReadyToRunComposite=true), controllable via the PublishReadyToRunStripILBodies MSBuild property. The composite gate is required because crossgen2 only accepts --strip-il-bodies in composite mode.

This re-applies #53947 (reverted in #54135) with the MSB4099 fix.

New behavior

The PublishReadyToRunStripInliningInfo, PublishReadyToRunStripDebugInfo, and PublishReadyToRunStripILBodies properties are now real opt-in toggles: each defaults to true only on the five Apple-mobile RIDs but can be set explicitly to true on any RID (e.g. osx-arm64) to take effect, instead of being silently ignored as before.

MSB4099 fix

The original PR placed the property assignments inside the import-time <PropertyGroup> at the top of Microsoft.NET.CrossGen.targets. Two of the conditions referenced items:

'@(PublishReadyToRunPartialAssemblies)' == '' and '@(PublishReadyToRunCompositeExclusions)' == ''

MSBuild forbids item-list references in property conditions evaluated at import time, raising MSB4099: A reference to an item list at position N is not allowed in this condition. This blocked any project that imported the targets when an Apple-mobile RID was set, surfacing in CI as a WasmAoTPublishIntegrationTest.AoT_Publish_WithExistingWebConfig_Works failure.

The fix moves the <PublishReadyToRunCrossgen2CompositeExtraArgs> computation into the body of the existing _PrepareForReadyToRunCompilation target, where item references are evaluated at target execution time. The gating semantics from #53947 are preserved exactly:

  • PublishReadyToRunStripILBodies != 'false'
  • PublishReadyToRunComposite == 'true'
  • @(PublishReadyToRunPartialAssemblies) is empty
  • @(PublishReadyToRunCompositeExclusions) is empty
  • RID is one of ios-, tvos-, iossimulator-, tvossimulator-, maccatalyst-

The _PrepareForReadyToRunCompilation target is non-batched and runs before _CreateR2RImages via DependsOnTargets, so the property is computed exactly once and available when the RunReadyToRunCompiler task is invoked.

cc @jkoritzinsky @MichaelSimons

Copilot AI review requested due to automatic review settings April 29, 2026 09:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes an MSBuild evaluation regression (MSB4099) in Microsoft.NET.CrossGen.targets caused by referencing item lists in import-time property conditions, by deferring computation of --strip-il-bodies arguments to target execution time.

Changes:

  • Removed import-time PublishReadyToRunCrossgen2CompositeExtraArgs assignments that referenced item lists (illegal at import time).
  • Reintroduced the --strip-il-bodies gating logic inside the _CreateR2RImages target where item list references are allowed.
Show a summary per file
File Description
src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.CrossGen.targets Moves composite --strip-il-bodies arg computation from import-time to target-time to avoid MSB4099.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

Comment thread src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.CrossGen.targets Outdated
@kotlarmilos kotlarmilos self-assigned this Apr 29, 2026
@kotlarmilos kotlarmilos added this to the 11.0.1xx milestone Apr 29, 2026
@kotlarmilos kotlarmilos force-pushed the fix-r2r-strip-il-bodies-msb4099 branch from aabba2b to b0c8b6e Compare April 29, 2026 13:56
@kotlarmilos kotlarmilos changed the title Fix MSB4099 in Microsoft.NET.CrossGen.targets from #53947 Add --strip-il-bodies crossgen2 arg for Apple mobile RIDs Apr 29, 2026
@kotlarmilos kotlarmilos force-pushed the fix-r2r-strip-il-bodies-msb4099 branch from b0c8b6e to 845fd79 Compare April 29, 2026 14:08
Comment thread src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.CrossGen.targets Outdated
Mirror the changes from dotnet/runtime#125647.

For Apple mobile RIDs (ios-, tvos-, iossimulator-, tvossimulator-, maccatalyst-),
pass --strip-il-bodies to crossgen2 by default via PublishReadyToRunCrossgen2CompositeExtraArgs
when composite R2R is enabled (PublishReadyToRunComposite=true), controllable via the
PublishReadyToRunStripILBodies MSBuild property. The composite gate is required because
crossgen2 only accepts --strip-il-bodies in composite mode.

This re-applies dotnet#53947 (reverted in dotnet#54135) with the MSB4099 fix: the property assignments
that reference @(PublishReadyToRunPartialAssemblies) and @(PublishReadyToRunCompositeExclusions)
items are placed inside the _PrepareForReadyToRunCompilation target body so the item references
are evaluated at target time rather than at import time.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@kotlarmilos kotlarmilos force-pushed the fix-r2r-strip-il-bodies-msb4099 branch from 845fd79 to ef3a422 Compare April 29, 2026 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants