-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
The analyzer assembly references version '4.6.0.0' of the compiler, which is newer than the currently running version '4.5.0.0' #66918
Comments
The fact that analyzer assemblies require a minimum required compiler version is by-design. Not sure if it is possible to detect that the compiler is referenced from Microsoft.Net.Compilers.Toolset and then produce a customized message? I guess we can add a property to |
I don't disagree here. I'm new to the codebase I'm working on, and the error message wasn't really helpful. |
Possibly. @RussKie Any idea why you have that reference to Microsoft.Net.Compilers.Toolset in the first place? (tagging @jaredpar and @tmat, who was recently trying to understand scenarios where folks are doing this) |
A scenario I know of is building against different versions of the .NET SDK (6 and 7), and we want to use the same version of the compiler, so we use Another scenario I can think of is faster adoption of new versions. |
What does it mean "building against different versions of the .NET SDK"? Wouldn't multi-targeting the project to
Why doesn't setting the SDK version in global.json and using the compiler from that SDK achieve that? |
In the general case, yes, multi-targeting with .NET 7 SDK should work. But there is dotnet/sdk#30103 that prevents that from happening.
Sometimes the NuGet package ships faster than the .NET SDK. |
I'd consider that super niche scenario though that we do not support. It might mean some IDE features are broken. |
There's also a general risk that if you move newer at one point, you then forgot you updated that and a few years later you're still using a pinned old version, and you don't realize that. That can result in general issues too as we move targets forward and such. We often find ourselves with customers complaining about bugs we already fixed, only to realize they had pinned their compiler version sometime in the past and then forgot. |
@jasonmalinowski I was told the team had issues with the 7.0.10x SDK and had to reference Microsoft.Net.Compilers.Toolset to work around those. @geeknoid / @tekian can provide more information on that. |
The The documentation for the package is very explicit about this
|
Yeah, this is something we probably need to do a better job then: if we're suggesting this package be installed for some specific case, we need to clearly communicate when we think that reference can be removed. Otherwise you're running a workaround that will indeed only explode later, as @jaredpar warns. Not your fault, just a lesson for us. |
@jaredpar I kind of feel we're talking about different issues here. I'm not arguing that this package has to work long term. The issue is that there is no mechanism to know that a) this package is installed and b) it has to be removed. E.g., if one engineer installed a package to resolve an issue, another engineer may not know that, then upon the SDK update everything breaks. Even if there's some kind of comment next to the package reference import, how would the second engineer know what to look for given the current error message? |
That is true for any package though. This package is explicitly not supported because we understand this can be the case and cause confusion over the long term in builds. We've gone as far as we can think of to make it clear this isn't supported without making it physically hard to install. |
I fixed the exact same issue by replacing the oldest dotnet Microsoft.NET.Sdk.Razor.SourceGenerators.dll file with the latest. In my case this was updating the dotnet 7 file with the dotnet 8 file so that they matched. Put simply, copy paste the Microsoft.NET.Sdk.Razor.SourceGenerators.dl file from the newest dotnet "source-generators" folder to the other versions of dotnet within the same folder name. Hope this makes sense. |
I hit this trying to build an older branch of the .NET SDK because the global.json from arcade was pinning to an older assembly version. Anyone else who hits this with a dev sdk should try to update their |
A little late to the party -- For me, it was a matter of "Am I using MsBuild or DotNet sdk"? The issue is a lot more visible when viewing your code in Rider... As you can see here, there is the dotnet version, and the msbuild version of "ms build". The MsBuild version comes installed with Visual Studio and can't be modified as easily without upgrading your Visual Studio. So in my problem, I had a .sln file with both .net core and .net framework csprojs. I could not build using dotnet because the .net framework didn't restore packages properly. And I couldn't build using MsBuild because I have analyzers using 4.7,0.0, but the MsBuild version of the analyzer was 4.5.0.0 as you can confirm in this picture: So if you hit a rock like I did for... far too long, try seeing if your Visual Studio is up-to-date. I can now build both using the msbuild.exe. |
I'm working on a non-public project. I can provide a repro and/or binlog via Teams.
Having moved to the latest .NET SDK from:
...to
I'm no longer able to build:
Welp? :)
The text was updated successfully, but these errors were encountered: