-
Notifications
You must be signed in to change notification settings - Fork 5k
System.Text.Json code gen: Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.0.0.0 #58502
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
Comments
Tagging subscribers to this area: @Anipik, @safern, @ViktorHofer Issue DetailsI upgraded to the latest daily System.Text.Json nuget package (6.0.0-rc.2.21451.3) and my project no longer builds. Visual Studio 2022 is really not helpful. It simply says:
However, if I invoke
I added
|
Tagging subscribers to this area: @eiriktsarpalis, @layomia Issue DetailsI upgraded to the latest daily System.Text.Json nuget package (6.0.0-rc.2.21451.3) and my project no longer builds. Visual Studio 2022 is really not helpful. It simply says:
However, if I invoke
I added
|
I tried adding System.Text.Json v6.0.0-rc.2.21451.3 to a source gen project but it seems to run without issue in both VS2022 and the CLI. My sdk version is
|
I can reproduce the error using the steps that you provided, however the error went away as soon as I removed the I'm not sure if source generation is meant to be supported using v5 SDKs. @layomia or @eerhardt might know. |
@Jericho - I know this isn't ideal, but try to set This is because we moved to the "incremental source generator API", and initially incremental generators need preview langversion. See dotnet/roslyn#55866. Note this restriction has been lifted in the latest Roslyn. Regarding VS 2019: the latest packages don't work with older Roslyn. I am working on that with #58536. |
I have removed global.json, switched to net6.0 and also added @eerhardt thank you for the links to other issues. Do I understand 58536 correctly that using Json code generator will prevent me from multi-targeting? |
No that isn't the case. In #58536, the term "multi-targeting" is referring to which version of the Roslyn compiler is being targeted by the source Json code generator. If it only targets the latest Roslyn version, it means the Json code generator won't be able to work in VS 2019, which has an older Roslyn version. User projects can target multiple TFMs (netstandard2.0, net5.0, etc) just the same as they were previously with no issues. |
@eerhardt it looks like the question has been answered and the underlying issues are being addressed. Can we close this issue? |
@eerhardt thank you for the clarification |
I upgraded to the latest daily System.Text.Json nuget package (6.0.0-rc.2.21451.3) and my project no longer builds.
Visual Studio 2022 is really not helpful. It simply says:
However, if I invoke
dotnet.exe build
from command prompt, I get a more helpful message:I added
<PackageReference Include="Microsoft.CodeAnalysis" Version="4.0.0-3.final" />
to my csproj but unfortunately it didn't help.The text was updated successfully, but these errors were encountered: