Skip to content

Pin the compiler version in RSG to an exact version #24130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 28, 2022

Conversation

pranavkm
Copy link
Contributor

Addresses #23972

@ghost ghost added the Area-AspNetCore RazorSDK, BlazorWebAssemblySDK, dotnet-watch label Feb 28, 2022
@@ -11,8 +11,14 @@
<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@eerhardt \ @MichaelSimons wanted to get your thoughts on this, as an enhancement to https://github.com/dotnet/sdk/pull/22072/files. Users are often affected by this when running a fairly new SDK using MSBuild where the compiler hasn't been updated as yet.

Copy link
Member

Choose a reason for hiding this comment

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

I think this is a bigger issue / question for the SDK and Roslyn teams. cc @jaredpar @chsienki @dsplaisted

So the repro steps here are:

  1. Install VS 2022, but not the latest version
  2. Install .NET Core SDK 6.0.200

and now we don't have a coherent SDK + VS? There are components in the 6.0.200 SDK that reference Roslyn 4.1, but the VS 2022 installed only has Roslyn 4.0?

Is that all true?

IMO - we shouldn't be using different version when building from source vs. building for Microsoft distribution. That's a recipe for disaster.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interestingly, this appears to be the path the ApiCompatibility tool has taken - https://github.com/dotnet/sdk/pull/23321/files

Copy link
Member

Choose a reason for hiding this comment

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

Agreed - I wasn't excited about that change either 😄. The difference with the ApiCompatibility tool is that it also ships OOB from the SDK into it's own NuGet package:

https://www.nuget.org/packages/Microsoft.DotNet.Compatibility

So someone could be using an older SDK, and PackageReference the newer version of that NuGet package.

Correct me if I'm wrong, but I believe that the Razor Source Generator only ships as part of the SDK, right? Shouldn't we have a guaranteed version of Roslyn that the SDK supports?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct me if I'm wrong, but I believe that the Razor Source Generator only ships as part of the SDK, right?

That is right.

Shouldn't we have a guaranteed version of Roslyn that the SDK supports?

👍🏽

Copy link
Member

Choose a reason for hiding this comment

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

Pinning the compiler means that you're not getting bug fixes, features, etc ...

It's less important for a tool like API Compat which is using us for a limited use case. Mostly to grab a semantic model to inspect the code. Much more important for components that are actually participating in mainline compilation.

In this case though this is not pinning the compiler, it's pinning the Compiler API version Razor is compiling against. At runtime we're going to use the MS.CA that ships with the compiler. Still though this feels very unnecessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jaredpar do you have suggestions on how we should proceed here? Users can unblock themselves by updating their VS / pinning the SDK, but both of these seem like crummy option.

Would we be open to taking this PR for 6.0.x and consider something more lasting for 7.0?

Copy link
Member

@eerhardt eerhardt Mar 1, 2022

Choose a reason for hiding this comment

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

Is this the only analyzer / source generator that actually ships in box with the SDK? I know that the roslyn-analyzer pin their version way back to something like 3.3.

We could follow that path here, and then for source-build, we need to put the ref assemblies for the version you pin in the "SBRP".

https://github.com/dotnet/roslyn-analyzers/blob/eb9a7a5d2e4dcbfd4db89c2ee48e79bca107484c/eng/Versions.props#L45-L57

Copy link
Contributor Author

@pranavkm pranavkm Mar 1, 2022

Choose a reason for hiding this comment

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

Is this the only analyzer / source generator that actually ships in box with the SDK?

ASP.NET Core builds some analyzers that ship as part of the WebSDK. Those are currently pinned to build against 3.3:

https://github.com/dotnet/aspnetcore/blob/main/eng/Versions.props#L198-L199

Edit: This particular source generator relies on IIncrementalGenerator which is only available in 4.0 or newer versions of the compiler.

Copy link
Member

Choose a reason for hiding this comment

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

Opened dotnet/source-build-reference-packages#357 to add the required bits to SBRP so we can target the same version in source build.

@SteveSandersonMS
Copy link
Member

@pranavkm Who would be most relevant to take on ownership of this PR (or the underlying issue) after this week? It sounds like @eerhardt or @jaredpar have the most context, and perhaps views on the correct way to proceed.

@jaredpar
Copy link
Member

@RikkiGibson, @jcouv FYI

@RikkiGibson
Copy link
Member

I didn't think this was a supported scenario--using a VS with an older version of the compiler than what's in the SDK. Did I misunderstand something?

@chsienki
Copy link
Member

@RikkiGibson We're still defining the exact support policy, but it is expected to work in some scenarios. In this case the generator isn't actually using any of the new features, it's just picking up a ref to latest MS.CA by default, so we want to change it so it will continue to load and work in downstream compilers.

Copy link
Member

@RikkiGibson RikkiGibson left a comment

Choose a reason for hiding this comment

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

Thanks for clarifying.

@chsienki chsienki mentioned this pull request Mar 25, 2022
@chsienki chsienki merged commit 4ac9854 into main Mar 28, 2022
@RikkiGibson RikkiGibson deleted the prkrishn/pin-compiler-version branch March 28, 2022 20:42
chsienki added a commit that referenced this pull request Mar 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-AspNetCore RazorSDK, BlazorWebAssemblySDK, dotnet-watch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants