Skip to content

Gate ILCompiler pack version update to explicit references - #130098

Merged
sbomer merged 2 commits into
dotnet:mainfrom
sbomer:ilc-implicit-fix
Jul 3, 2026
Merged

Gate ILCompiler pack version update to explicit references#130098
sbomer merged 2 commits into
dotnet:mainfrom
sbomer:ilc-implicit-fix

Conversation

@sbomer

Copy link
Copy Markdown
Member

Fixes a stale restore/design-time restore interaction where imported Microsoft.DotNet.ILCompiler package targets could overwrite the SDK bundled KnownILCompilerPack version from an old assets file.

The package targets still update KnownILCompilerPack for explicit Microsoft.DotNet.ILCompiler PackageReference entries, preserving the documented custom/daily ILC package scenario, but they no longer do so for SDK-generated implicit references.

Validation:

  • Verified implicit PackageReference keeps the SDK bundled ILCompiler version while explicit PackageReference still updates KnownILCompilerPack to the package version.
  • Reproduced the SDK upgrade stale-assets scenario with SDK 10.0.100 -> 10.0.103 and verified CollectPackageReferences now reports Microsoft.DotNet.ILCompiler 10.0.3 instead of stale 10.0.0.

Only update KnownILCompilerPack from the ILCompiler package targets when the project has an explicit Microsoft.DotNet.ILCompiler PackageReference. This preserves the SDK bundled version for implicit package references during design-time restore with stale assets.
Assisted-by: GitHub Copilot CLI:gpt-5.5
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR changes NativeAOT build integration so the Microsoft.DotNet.ILCompiler package’s imported .targets only updates KnownILCompilerPack when there is an explicitPackageReference to Microsoft.DotNet.ILCompiler, preventing implicit (SDK-generated) references from overriding the SDK-bundled pack version.

Changes:

  • Replaces an evaluation-time ItemGroup update of KnownILCompilerPack with a target that runs BeforeTargets="ProcessFrameworkReferences".
  • Adds a guard intended to apply the KnownILCompilerPack version update only when Microsoft.DotNet.ILCompiler is explicitly referenced (non-implicit PackageReference).
Show a summary per file
FileDescription
src/coreclr/nativeaot/BuildIntegration/Microsoft.DotNet.ILCompiler.SingleEntry.targetsGates updating KnownILCompilerPack to explicit Microsoft.DotNet.ILCompiler package references and moves the update to a pre-ProcessFrameworkReferences target.

Copilot's findings

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

Compute explicit Microsoft.DotNet.ILCompiler package references into a helper item before updating KnownILCompilerPack. This keeps the update deterministic while preserving the explicit package reference behavior.
Assisted-by: GitHub Copilot CLI:gpt-5.5
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jkotas

Copy link
Copy Markdown
Member

Does #119166 (comment) still work with this change?

@build-analysisbuild-analysisBot mentioned this pull request Jul 2, 2026
@sbomer

Copy link
Copy Markdown
MemberAuthor

Yes, I've confirmed that workaround still works.

@sbomer
sbomer merged commit 80716bc into dotnet:mainJul 3, 2026
109 of 111 checks passed
@dotnet-milestone-botdotnet-milestone-botBot added this to the 11.0-preview7 milestone Jul 4, 2026
@sbomer
sbomer deleted the ilc-implicit-fix branch July 6, 2026 16:52
eiriktsarpalis pushed a commit that referenced this pull request Jul 15, 2026
Fixes a stale restore/design-time restore interaction where imported
Microsoft.DotNet.ILCompiler package targets could overwrite the SDK
bundled KnownILCompilerPack version from an old assets file.
The package targets still update KnownILCompilerPack for explicit
Microsoft.DotNet.ILCompiler PackageReference entries, preserving the
documented custom/daily ILC package scenario, but they no longer do so
for SDK-generated implicit references.
Validation:
- Verified implicit PackageReference keeps the SDK bundled ILCompiler
version while explicit PackageReference still updates
KnownILCompilerPack to the package version.
- Reproduced the SDK upgrade stale-assets scenario with SDK 10.0.100 ->
10.0.103 and verified CollectPackageReferences now reports
Microsoft.DotNet.ILCompiler 10.0.3 instead of stale 10.0.0.
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Aug 6, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants

@sbomer@jkotas@MichalStrehovsky