I have a .NET 6 MVC app, and a class library.
In the class library, I wanted to use a source generator.
I added the NuGet package Microsoft.CodeAnalysis.Analyzers and Microsoft.CodeAnalysis.CSharp.Workspaces to my class library
However I get this error:
Version conflict detected for Microsoft.CodeAnalysis.Common. Install/reference Microsoft.CodeAnalysis.Common 4.3.0 directly to project MyMVCApp to resolve this issue.
MyMVCApp -> MyClassLibrary -> Microsoft.CodeAnalysis.CSharp.Workspaces 4.3.0 -> Microsoft.CodeAnalysis.Common (= 4.3.0)
MyMVCApp -> Microsoft.VisualStudio.Web.CodeGeneration.Design 6.0.7 -> Microsoft.DotNet.Scaffolding.Shared 6.0.7 -> Microsoft.CodeAnalysis.CSharp.Features 4.0.0 -> Microsoft.CodeAnalysis.Common (= 4.0.0). MyMVCApp C:\x\MyMVCApp.csproj 1
I can't see a way to resolve this, confused why there's a hard coded requirement for version 4 or why it can't work around it. Any ideas? I'm not au fait with diagnosing this type of issue.
I should add, I tried doing what it said but it just gave me the conflict message and said "Package restore failed. Rolling back package changes".