-
Notifications
You must be signed in to change notification settings - Fork 1.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
JsonSourceGenerator cannot be created in VS2019 preview #21006
Comments
This comment has been minimized.
This comment has been minimized.
+1 on this. Trying to bump up our build to use RC1 and getting the following errors:
We don't even use System.Text.Json.SourceGeneration.dll in our code. Disabling the Analyzers is not an acceptable workaround as we will not be in compliance. |
I imagine #20793 and dotnet/runtime#58446 could help with this. On the other hand, #20987 would add a warning. |
FYI @layomia |
As mentioned in #20987, in order to target One reason it is not supported is because the version of the compiler you get in VS 2019 is the version of Roslyn that shipped with .NET 5.0 - Roslyn version 3.11. That is why you are seeing that error:
The source generators that ship with net6.0 depend on Roslyn 4.0. Trying to load them in VS 2019 doesn't work. There are other features in net6.0 that won't work in VS 2019 as well - for example workloads, new language features like global usings, file-scoped namespaces, new interpolated string features, etc. |
A more targeted workaround for this specific issue would be: <Target Name="_RemoveFrameworkReferenceAnalyzers"
AfterTargets="ResolveTargetingPackAssets">
<ItemGroup>
<Analyzer Remove="@(Analyzer)" Condition="'%(Analyzer.FrameworkReferenceName)' != ''" />
</ItemGroup>
</Target> Which will only remove the Json source generator, and not other analyzers (which are pretty important, since they help you write correct code). But this is only a band-aid to the issue. The real solution is to use VS 2022. |
firstly, thanks to all for the quick responses and help.
Is this a temporary state that will be fixed, or is the intent that net6 will only be supported on VS2022 |
@odhanson try this work around for the one Analyzer
|
can anyone explain why System.Text.Json.SourceGeneration is even bein executed when i dont use System.Text.Json? |
The intent is that net6 will only be supported on VS 2022. See https://devblogs.microsoft.com/dotnet/announcing-net-6-rc1/:
And #20987, which will add an explicit warning in RC2 that says "NETSDK1182: Targeting .NET 6.0 in Visual Studio 2019 is not supported."
When you target net6.0, there are a bunch of libraries that automatically get included by default.
|
@eerhardt thanks for the clarifications. Given the issue as described isnt a supported scenario, i will close this one |
Describe the bug
Updated to dotnet 6 sdk rc1 ( 6.0.100-rc.1.21458.32). Now VS (16.11.3 Preview 1.0) fails with:
Does not occur when running
dotnet build
from the command lineIt is also strange since i do not directly reference the
System.Text.Json
nuget.To Reproduce
I am able to reproduce by building this https://github.com/VerifyTests/Verify/tree/WithGenFailure
Further technical details
dotnet --info
VS info:
Workaround
The text was updated successfully, but these errors were encountered: