Skip to content

Comments

Fix _TouchAndroidLinkFlag skipping on NativeAOT incremental builds#10849

Merged
jonathanpeppers merged 1 commit intomainfrom
dev/sbomer/androidLinkFlagFix
Feb 20, 2026
Merged

Fix _TouchAndroidLinkFlag skipping on NativeAOT incremental builds#10849
jonathanpeppers merged 1 commit intomainfrom
dev/sbomer/androidLinkFlagFix

Conversation

@sbomer
Copy link
Member

@sbomer sbomer commented Feb 20, 2026

Add '$(RunILLink)' != 'false' to the Condition of _TouchAndroidLinkFlag so it Condition-skips in lockstep with the ILLink target it hooks via AfterTargets. This works around an MSBuild behavior (dotnet/msbuild#13274) where AfterTargets hooks may fire before the target actually executes, leading to a stale flag.

Without this fix, _TouchAndroidLinkFlag's Inputs/Outputs check sees stale timestamps on the first (skipped) ILLink invocation and skips itself, then never runs again when ILLink actually executes. This can sometimes cause link.flag to go stale, which can cause _RemoveRegisterAttribute and the AssemblyModifierPipeline to skip on incremental builds.

Fixes an issue I found in #10704. Opening as a separate PR to test it in isolation.

Add '$(RunILLink)' != 'false' to the Condition of _TouchAndroidLinkFlag
so it Condition-skips in lockstep with the ILLink target it hooks via
AfterTargets. This works around an MSBuild behavior (dotnet/msbuild#13274)
where AfterTargets hooks may fire before the target actually executes,
leading to a stale flag.

Without this fix, _TouchAndroidLinkFlag's Inputs/Outputs check sees
stale timestamps on the first (skipped) ILLink invocation and skips
itself, then never runs again when ILLink actually executes.  This
can sometimes cause link.flag to go stale, which can cause
_RemoveRegisterAttribute and the AssemblyModifierPipeline to skip on
incremental builds.
Copilot AI review requested due to automatic review settings February 20, 2026 20:58
Copy link

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

Adjusts the _TouchAndroidLinkFlag MSBuild target so it skips in the same cases as the ILLink target it hooks into, preventing stale link.flag behavior on NativeAOT incremental builds due to MSBuild AfterTargets scheduling quirks.

Changes:

  • Update _TouchAndroidLinkFlag to additionally require $(RunILLink) != 'false' in its Condition, aligning its execution with ILLink.

@jonathanpeppers jonathanpeppers merged commit f19c1fc into main Feb 20, 2026
9 of 10 checks passed
@jonathanpeppers jonathanpeppers deleted the dev/sbomer/androidLinkFlagFix branch February 20, 2026 23:12
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.

2 participants