Microsoft.CodeAnalysis.CSharp 和 Microsoft.CodeAnalysis - 系统找不到指定的文件
所以问题是,我有 .NET 6。然后我执行dotnet Restore
。之后,我想做 dotnet format -v diag --report ./editor-report.json --verify-no-changes example.sln。
但格式化后我得到了这个错误:
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.
然后我想也许我可以安装该依赖项。但我不能。
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.
我该如何修复它?顺便说一句,.NET 5
扫描表现良好。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在 GitHub Actions 中注意到了同样的问题,但无法在本地重现。
根据 此 GitHub 问题,它似乎与版本
6.0.200。该线程中的建议是重命名
6.0.200
或完全卸载它,但我还没有找到其他解决方法。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 rename6.0.200
or uninstall it entirely, but I haven't found another workaround.