使用sonarQube分析c#代码:MSBUILD版本问题

时间:2017-07-04 14:28:03

标签: c# visual-studio msbuild sonarqube sonarqube-scan

我需要分析各种C#文件(不是项目,只是放在同一目录下的.cs文件)。

我以两种不同的方式尝试分析,每次都有错误。有人可以帮助解决任何这些错误吗?

1-我尝试过像here

这样的分析

通过在根文件中执行C:\ sonar-scanner \ bin \ sonar-scanner.bat,我有这个错误

ERROR: Error during SonarQube Scanner execution
java.lang.IllegalArgumentException: Custom and 3rd party Roslyn analyzers 
are only by MSBuild 14. Either use MSBuild 14, or disable the custom/3rd 
party Roslyn analyzers in your quality profile.

2-我厌倦了创建项目并使用SonarQube Scanner for MSBuild

进行分析

但最后,我出现了这个错误

The SonarQube MSBuild integration failed: SonarQube was unable to collect 
the required information about your projects.
Possible causes:
 1. The project has not been built - the project must be built in between 
the begin and end steps
 2. An unsupported version of MSBuild has been used to build the project. 
 Currently MSBuild 14.0 upwards are supported
 3. The begin, build or end steps have not all been launched from the 
 same folder
 Generation of the sonar-properties file failed. Unable to complete 
 SonarQube analysis.

我安装了Visual Studio 2015,2012,2010,2008。如何验证我使用正确的MSBUILD verison(14),因为我检查了C:\ Program Files(x86)\ MSBuild,我在那里找到了版本14.

还有其他问题要处理吗?

最后,我需要能够以第一种和第二种方式进行分析。

提前谢谢!

1 个答案:

答案 0 :(得分:1)

  

2-我厌倦了创建项目并使用SonarQube Scanner进行MSBuild分析

根据该文档,我们需要从您要分析的项目的根文件夹中执行以下命令:

SonarQube.Scanner.MSBuild.exe begin /k:"org.sonarqube:sonarqube-scanner-msbuild" /n:"Project Name" /v:"1.0"
MSBuild.exe /t:Rebuild
SonarQube.Scanner.MSBuild.exe end

但命令MSBuild.exe是一个外部命令,Windows无法在任意目录中识别,你应该添加MSBuild路径“C:\ Program Files(x86)\ MSBuild \ 14.0 \ Bin”进入您的系统环境以使开始,构建或结束步骤都从同一文件夹启动。

相关问题