Skip to content

Use N-1 SB version for source generators only#4657

Merged
mthalman merged 3 commits intodotnet:mainfrom
mthalman:dev/mthalman/sb5355-aspnet-source-generator
Feb 11, 2026
Merged

Use N-1 SB version for source generators only#4657
mthalman merged 3 commits intodotnet:mainfrom
mthalman:dev/mthalman/sb5355-aspnet-source-generator

Conversation

@mthalman
Copy link
Copy Markdown
Member

@mthalman mthalman commented Feb 4, 2026

Fixes dotnet/source-build#5355

Removes the temporary workaround that changed Roslyn to always use N-1 artifacts in source-only builds. Replaces it with a more targeted solution that only uses N-1 artifacts for analyzers/source generators that get executed during the same build in which they were produced (in which case N-1 artifacts are the only option).

Copilot AI review requested due to automatic review settings February 4, 2026 19:48
@mthalman mthalman requested review from a team as code owners February 4, 2026 19:48
@dotnet-policy-service dotnet-policy-service Bot requested review from a team February 4, 2026 19:49
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

This PR replaces a temporary broad workaround with a more targeted solution for Roslyn versioning in source-build scenarios. Instead of using N-1 (previous) Roslyn artifacts for everything, the PR introduces a new property MicrosoftCodeAnalysisSourceGeneratorVersion that specifically targets source generators that get executed during the same build in which they're produced.

Changes:

  • Introduces MicrosoftCodeAnalysisSourceGeneratorVersion property that defaults to the latest VS Roslyn version but gets overridden to N-1 in source-build
  • Updates RequestDelegateGenerator to use the new targeted property instead of the general MicrosoftCodeAnalysisVersion_LatestVS
  • Expands CS9057 suppression from non-official source-only builds to all source-only builds in projects that distribute analyzers

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/aspnetcore/eng/Versions.props Defines the new MicrosoftCodeAnalysisSourceGeneratorVersion property with appropriate documentation
src/aspnetcore/src/Http/Http.Extensions/gen/Microsoft.AspNetCore.Http.RequestDelegateGenerator/Microsoft.AspNetCore.Http.RequestDelegateGenerator.csproj Updates the source generator to use the new targeted version property
repo-projects/aspnetcore.proj Configures source-build to set the new property to N-1 Roslyn version while allowing other code to use current version
src/sdk/src/WebSdk/Web/Tasks/Microsoft.NET.Sdk.Web.Tasks.csproj Expands CS9057 suppression condition and improves documentation to cover both dev/ci and version upgrade scenarios
src/sdk/src/BuiltInTools/dotnet-watch/dotnet-watch.csproj Expands CS9057 suppression condition and improves documentation to cover both dev/ci and version upgrade scenarios

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread repo-projects/aspnetcore.proj Outdated
@dotnet-policy-service dotnet-policy-service Bot requested review from a team February 4, 2026 21:28
@jkoritzinsky
Copy link
Copy Markdown
Member

Cc @sbomer this might be a good path for the runtime work to go

@sbomer
Copy link
Copy Markdown
Member

sbomer commented Feb 5, 2026

I think this approach won't work for dotnet/runtime#123559 because it looks like the "previous" versions are only available for DotNetBuildSourceOnly. We need to ensure a consistent shipping version for the official product build too.

I thought these weren't being used since nothing directly referenced
these names. But they actually are being referenced due to dynamically
generated property names.
@mthalman mthalman requested a review from wtgodbe February 6, 2026 13:44
@mthalman
Copy link
Copy Markdown
Member Author

@dotnet/source-build - Please review

@mthalman mthalman merged commit c7b9b2e into dotnet:main Feb 11, 2026
11 checks passed
@mthalman mthalman deleted the dev/mthalman/sb5355-aspnet-source-generator branch February 11, 2026 20:47
mthalman added a commit to mthalman/dotnet that referenced this pull request Feb 12, 2026
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.

RequestDelegateGenerator compiler version mismatch

7 participants