微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

SonarQube找不到Microsoft.CodeAnalysis 1.3.1.0,但已安装

如何解决SonarQube找不到Microsoft.CodeAnalysis 1.3.1.0,但已安装

我试图对我的C#项目运行SonarQube扫描。我有3个项目和1个解决方文件

我跑步:

SonarScanner.MSBuild.exe begin /o:"xxxxxxxxx" /k:"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"     
/d:sonar.host.url="https://sonarcloud.io" /d:sonar.login="xxxxxxxxxxxxxxxxxxxxxxxxxxx"
MSBuild.exe  Cake.Framework.sln /t:Rebuild
SonarScanner.MSBuild.exe /d:sonar.login="xxxxxxxxxxxxxxxxxxxxxxx" end

然后我在cmd上看到了

 SonarScanner for MSBuild 4.10
 Using the .NET Framework version of the Scanner for MSBuild
 Pre-processing started.
 Preparing working directories...
 Updating build integration targets...
 Fetching analysis configuration settings...
 Provisioning analyzer assemblies for cs...
 Installing required Roslyn analyzers...
 Provisioning analyzer assemblies for vbnet...
 Installing required Roslyn analyzers...
 Pre-processing succeeded.

 C:\Users\santi\Desktop\20200422_Cake.Framework-master>MSBuild.exe  Cake.Framework.sln /t:Rebuild
 Microsoft (R) Build Engine,versión 14.0.23107.0

一切似乎都很好,但突然间我收到了1000多个这样的警告:

 CSC : warning CS8032: Couldnt create an analyzer instance     
 Sonaranalyzer.Rules.CSharp.PartCreationPolicyShouldBeUsedWithExportAttribute from 
 C:\Users\santi\AppData\Local\Temp\.sonarqube\resources\0\Sonaranalyzer.CSharp.dll : Could not load 
 file or assembly 'Microsoft.CodeAnalysis,version= 1.3.1.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file 
 specified. [C:\Users\santi\Desktop\20200422_Cake.Framework-master\Cake.Framework\Cake.Framework.csproj]

我已经使用NuGet Manager在我的所有3个项目中都安装了Microsoft.CodeAnalysis v 1.3.1。

我缺少什么?

我正在使用.NET Framework 4.8,MSBuild 14.0,Visual Studio 2019

解决方法

您不需要在项目中安装代码分析NuGet软件包。

重要的是,用于构建解决方案的MSBuild版本附带的代码分析程序集的版本。检查您正在使用哪个版本的MSBuild(msbuild -ver)。它需要14.0.25420.1或更高版本。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。