Use N-1 SB version for source generators only#4657
Conversation
There was a problem hiding this comment.
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
MicrosoftCodeAnalysisSourceGeneratorVersionproperty that defaults to the latest VS Roslyn version but gets overridden to N-1 in source-build - Updates
RequestDelegateGeneratorto use the new targeted property instead of the generalMicrosoftCodeAnalysisVersion_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.
|
Cc @sbomer this might be a good path for the runtime work to go |
|
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.
|
@dotnet/source-build - Please review |
This reverts commit c7b9b2e.
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).