roslyn: Microsoft.CodeAnalysis.CSharp 4.3.0 fail to build source generators
Version Used: Microsoft.CodeAnalysis.CSharp 4.3.0
Steps to Reproduce:
- Create a source generator using Microsoft.CodeAnalysis.CSharp 4.3.0
- Add System.Text.Json to the project using this method https://github.com/dotnet/roslyn/discussions/47517#discussioncomment-1768639
- Create a project using the source generator
- Add a test project for the new project
- Build
- Generated code isn’t generated
Small repro here: https://github.com/erwan-joly/source-generator-bug-repro
Expected Behavior: It shouldn’t fail the build. It’s a regression as moving back to 4.2.0 compile fine
Actual Behavior:
warning CS8785: Generator 'Generator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'FileNotFoundException' with message 'Could not load file or assembly 'System.Collections.Immutable, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.'
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 15 (11 by maintainers)
Bug whack-a-mole… the preview3 package we suggested may predate #63347.
If you can add an additional nuget feed to your project then you might have success using the exact version we shipped in VS 17.3 (at time of writing).
I can see we’ve had several people hit this. I’ll follow up when we have a solution which addresses the root of the problem.
That’s not doing the trick in the MVVM Toolkit test projects. It no longer fails to create the generators, but it now crashes while building:
it’s still prevalent in Microsoft.CodeAnalysis.CSharp (Latest prerelease 4.4.0-3.22459.4) - had to downgrade to 4.2.0, too…