So the problem is, I have .NET 6. Then I do dotnet restore. After that, I want to do dotnet format -v diag --report ./editor-report.json --verify-no-changes example.sln.
But after formatting I got that error:
Analysis complete in 2554ms.
Unhandled exception: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Could not load file or assembly 'Microsoft.CodeAnalysis.CSharp, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
Then I think maybe I can just install that dependencies. But I can't.
dotnet tool install --global Microsoft.CodeAnalysis
/tmp/sf1h1yl0.gli/restore.csproj : error NU1212: Invalid project-package combination for Microsoft.CodeAnalysis 4.1.0. DotnetToolReference project style can only contain references of the DotnetTool type
The tool package could not be restored.
How can I fix it? By the way the .NET 5 scan is doing well.