Skip to content
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

Error CS8032 An instance of analyzer System.Text.Json.SourceGeneration.JsonSourceGenerator cannot be created from (...) #56738

Closed
augustoproiete opened this issue Sep 26, 2021 · 6 comments
Labels
Area-Compilers Resolution-By Design The behavior reported in the issue matches the current design

Comments

@augustoproiete
Copy link

Warning CS8032 System.Text.Json.SourceGeneration.JsonSourceGenerator cannot be created from ... when building a class library targeting net6.0 with .NET 6 RC1 SDK:0

Version Used:
SDK: 6.0.100-rc.1.21458.32
VS: 16.11.3

Steps to Reproduce:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFrameworks>net6.0;net5.0;netstandard2.0;net461</TargetFrameworks>

    <LangVersion>9.0</LangVersion>
    <Nullable>enable</Nullable>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
    <TreatSpecificWarningsAsErrors />
  </PropertyGroup>
 
</Project>

Expected Behavior:

No warnings or errors

Actual Behavior:

image

Error | CS8032 | An instance of analyzer System.Text.Json.SourceGeneration.JsonSourceGenerator cannot be created from C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.0-rc.1.21451.13\analyzers\dotnet\cs\System.Text.Json.SourceGeneration.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.. | NaturalStringExtensions (net6.0) | C:\augustoproiete\my-project\CSC | 1 | Active

Workaround:

Disable the warning CS8032:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFrameworks>net6.0;net5.0;netstandard2.0;net461</TargetFrameworks>

    <LangVersion>9.0</LangVersion>
    <Nullable>enable</Nullable>
    <NoWarn>$(NoWarn);CS8032</NoWarn>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
    <TreatSpecificWarningsAsErrors />
  </PropertyGroup>
 
</Project>
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Sep 26, 2021
augustoproiete added a commit to augustoproiete/NaturalStringExtensions that referenced this issue Sep 26, 2021
@svick
Copy link
Contributor

svick commented Sep 26, 2021

I believe if you want to use .Net 6, you need VS 2022. The error message is trying to tell you that: .Net 6 requires Roslyn version 4.0 and VS 2019 does not support that.

@augustoproiete
Copy link
Author

Thanks @svick. I suspect you're correct - though I have been using .NET 6.0.100-preview.4 and prior versions with VS2019 without issues, so it seems support for VS2019 has been dropped in more recent releases.

If you or anyone reading this know of any official announcement that .NET 6 requires VS2022 to work, please post here as I'm sure others will also expect .NET 6 to work with VS2019.

It would also be great if a check could be added, with a clear message that VS2019 is not supported.

@svick
Copy link
Contributor

svick commented Sep 26, 2021

I have been using .NET 6.0.100-preview.4 and prior versions with VS2019 without issues, so it seems support for VS2019 has been dropped in more recent releases.

If you or anyone reading this know of any official announcement that .NET 6 requires VS2022 to work, please post here as I'm sure others will also expect .NET 6 to work with VS2019.

Both the download page for .Net 6 RC1 and its release notes say that only VS 2022 is supported.

It seems preview 4 was the last version to support VS 2019.

@martincostello
Copy link
Member

There's also a recent change in dotnet/runtime to have the source generators multi-target for different Visual Studio versions: dotnet/runtime#59074

@jcouv
Copy link
Member

jcouv commented Sep 28, 2021

Closing the issue as by-design. Thanks

@jcouv jcouv closed this as completed Sep 28, 2021
@jcouv jcouv added Resolution-By Design The behavior reported in the issue matches the current design and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Sep 28, 2021
@shunyh
Copy link

shunyh commented Dec 26, 2022

@augustoproiete

Yes, it does not support VS2019.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Resolution-By Design The behavior reported in the issue matches the current design
Projects
None yet
Development

No branches or pull requests

5 participants