Add --strip-il-bodies crossgen2 arg for Apple mobile RIDs#54143
Open
kotlarmilos wants to merge 1 commit intodotnet:mainfrom
Open
Add --strip-il-bodies crossgen2 arg for Apple mobile RIDs#54143kotlarmilos wants to merge 1 commit intodotnet:mainfrom
kotlarmilos wants to merge 1 commit intodotnet:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
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
PublishReadyToRunCrossgen2CompositeExtraArgsassignments that referenced item lists (illegal at import time). - Reintroduced the
--strip-il-bodiesgating logic inside the_CreateR2RImagestarget 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
This was referenced Apr 29, 2026
aabba2b to
b0c8b6e
Compare
b0c8b6e to
845fd79
Compare
dsplaisted
approved these changes
Apr 29, 2026
rolfbjarne
approved these changes
Apr 29, 2026
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>
845fd79 to
ef3a422
Compare
rolfbjarne
approved these changes
Apr 29, 2026
This was referenced Apr 29, 2026
Open
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Mirror the changes from dotnet/runtime#125647.
For Apple mobile RIDs (
ios-,tvos-,iossimulator-,tvossimulator-,maccatalyst-), pass--strip-il-bodiesto crossgen2 by default viaPublishReadyToRunCrossgen2CompositeExtraArgswhen composite R2R is enabled (PublishReadyToRunComposite=true), controllable via thePublishReadyToRunStripILBodiesMSBuild property. The composite gate is required because crossgen2 only accepts--strip-il-bodiesin composite mode.This re-applies #53947 (reverted in #54135) with the MSB4099 fix.
New behavior
The
PublishReadyToRunStripInliningInfo,PublishReadyToRunStripDebugInfo, andPublishReadyToRunStripILBodiesproperties are now real opt-in toggles: each defaults totrueonly on the five Apple-mobile RIDs but can be set explicitly totrueon 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 ofMicrosoft.NET.CrossGen.targets. Two of the conditions referenced items: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 aWasmAoTPublishIntegrationTest.AoT_Publish_WithExistingWebConfig_Worksfailure.The fix moves the
<PublishReadyToRunCrossgen2CompositeExtraArgs>computation into the body of the existing_PrepareForReadyToRunCompilationtarget, 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 emptyios-,tvos-,iossimulator-,tvossimulator-,maccatalyst-The
_PrepareForReadyToRunCompilationtarget is non-batched and runs before_CreateR2RImagesviaDependsOnTargets, so the property is computed exactly once and available when theRunReadyToRunCompilertask is invoked.cc @jkoritzinsky @MichaelSimons