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

Source generator does not work as NuGet package in Visual Studio #3

Closed
SephDB opened this issue Jan 28, 2023 · 6 comments
Closed

Source generator does not work as NuGet package in Visual Studio #3

SephDB opened this issue Jan 28, 2023 · 6 comments
Labels
enhancement New feature or request

Comments

@SephDB
Copy link

SephDB commented Jan 28, 2023

When added as a NuGet library to a project in Visual Studio, the source generator gets an error that it can't be loaded because the dll for netstandard2.1 can't be found.

After some googling, it seems only netstandard2.0 source generators are supported by the IDE.
dotnet/roslyn#47087

Is it possible to downgrade to netstandard2.0?

@Difficulty-in-naming
Copy link
Contributor

Installing .net standard 2.1 with Visual Studio Installer may solve your problem.
Tested in Rider and Visual Studio 2022, works

@SephDB
Copy link
Author

SephDB commented Jan 29, 2023

I can't find anywhere to "install" .net standard 2.1, and all documentation on source generators in visual studio says only netstandard 2.0 is supported
https://learn.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/source-generators-overview
https://www.thinktecture.com/en/net/roslyn-source-generators-introduction/
That last one has this to say:

The target framework of the project containing the Source Generator should be set to netstandard2.0, otherwise some IDEs may refuse loading the DLL. For example, JetBrains Rider 2021.3.2 has no issues with netstandard2.1 but Visual Studio 2022 (17.0.4) demands netstandard2.0.

I haven't found anything to suggest that this situation has changed in the current version of VS(17.4.4)

If it matters, I'm doing this in a .NET 7 project

@Difficulty-in-naming
Copy link
Contributor

After checking the dependencies, it seems that only .net standard 2.0 is needed. Unity also only supports Roslyn for .net standard 2.0. Maybe we should bring down the API version?

@genaray
Copy link
Owner

genaray commented Jan 29, 2023

Approved, lets bring it down to .NetStandard 2.0 then :)

@genaray genaray added the enhancement New feature or request label Jan 29, 2023
@genaray genaray moved this to In Progress in Arch Roadmap Jan 29, 2023
genaray added a commit that referenced this issue Jan 29, 2023
…mentation for the source generator aswell as for the systems and samples.
@genaray
Copy link
Owner

genaray commented Jan 29, 2023

The source generator is now based on .NetStandard2.0, the latest nuget 1.0.7 is currently uploading :)
Let me know if it now works as expected!

@SephDB
Copy link
Author

SephDB commented Jan 29, 2023

Works perfect now, thanks!

@SephDB SephDB closed this as completed Jan 29, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in Arch Roadmap Jan 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

3 participants