Skip to content

Keep source-built ASP.NET Core analyzers bootstrap-compatible - #10335

Merged
mthalman merged 1 commit into
dotnet:mainfrom
mthalman:dev/mthalman/sb-analyzer-fix
Oct 20, 2026
Merged

mthalman merged 1 commit into
dotnet:mainfrom
mthalman:dev/mthalman/sb-analyzer-fix

Conversation

@mthalman

Copy link
Copy Markdown
Member

Problem

Error or behavior: Source-build fails with CS8032 while compiling Microsoft.DotNet.HotReload.Watch. ASP.NET Core analyzers and the validation generator cannot load System.Collections.Immutable, Version=12.0.0.0.

Root cause (high confidence): The source-only override for MicrosoftCodeAnalysisVersion_LatestVS selects current source-built Roslyn packages. Following the .NET 12 retargeting in #10156, these introduce dependencies on runtime assemblies unavailable to the bootstrap compiler, which runs on .NET 11.

Why PR source-build checks passed

The source-build jobs for #10156 ran and passed in public build 1641241, including the Microsoft-SDK and current-source-built-SDK legs.

Assembly metadata comparisons confirm that both the PR and failing official packages reference System.Collections.Immutable 12.0.0.0. However, their Roslyn references differ:

  • PR packages: Reference the non-official Microsoft.CodeAnalysis identity 42.42.42.42. Roslyn rejects these as targeting a newer compiler before instantiating analyzer types, reporting CS9057. Watch's existing source-only CS9057 suppression masks this skip.
  • Official packages: Reference Microsoft.CodeAnalysis 5.13.0.0, matching the bootstrap compiler. They pass the compiler-version check, then fail during initialization with CS8032 because the bootstrap runtime cannot load Immutable 12.0.0.0.

Both SDK binlogs identify the same bootstrap SDK and compiler. The incompatible dependency therefore exists in both builds but is masked in PR builds, not because source-build jobs were omitted or CS8032 was suppressed.

Description

Fix: Change the source-only override to use MicrosoftCodeAnalysisCommonPreviousVersion, keeping analyzer dependencies compatible with the bootstrap compiler and its runtime. This follows the existing previous-package approach used for ASP.NET Core source generators. Update the adjacent rationale accordingly.

Fixes dotnet/source-build#5674

Use previous Roslyn packages for source-only analyzer dependencies so they remain compatible with the bootstrap compiler and runtime.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 870e3b3c-1829-44c7-81fd-f26e992b792f
Copilot AI balanced review requested due to automatic review settings October 20, 2026 14:34
@mthalman
mthalman requested review from a team as code owners October 20, 2026 14:34
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI 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.

🟢 Approval recommended

The narrow override follows the existing bootstrap-version pattern, with no blocking issues identified in static review.

No open issues 🎉

What changed in this PR

Keeps source-built ASP.NET Core analyzers compatible with the bootstrap compiler and runtime.

Changes:

  • Uses the previous Roslyn package version for the source-only analyzer override.
  • Updates the comment to explain bootstrap compatibility.
File Description
repo-projects/​aspnetcore.proj Aligns analyzer dependencies with the existing bootstrap-compatible generator approach.

Review effort: Balanced

Comment thread repo-projects/aspnetcore.proj Resolved
@mthalman
mthalman enabled auto-merge (squash) October 20, 2026 15:57
@mthalman
mthalman merged commit ee5ace3 into dotnet:main Oct 20, 2026
11 checks passed
@mthalman
mthalman deleted the dev/mthalman/sb-analyzer-fix branch October 20, 2026 17:04
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.

[main] Source-build legs fail with CS8032 loading ASP.NET Core analyzers

5 participants