Reputation: 563
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.
Upvotes: 1
Views: 1672
Reputation: 148
I've noticed this same issue in GitHub Actions, but wasn't able to reproduce locally.
It seems, according to this GitHub issue, that it's related to having the version 6.0.200
of the SDK installed on your machine. The suggestions in that thread are to either rename 6.0.200
or uninstall it entirely, but I haven't found another workaround.
Upvotes: 1