SonarQube仅使用csproj即可从SLN进行分析

时间:2018-10-11 15:02:56

标签: c# msbuild sonarqube jenkins-pipeline sonarqube-scan

我想对我的sln文件运行SonarQube分析,这意味着该文件中包含所有csproj。 显然我在配置中遗漏了一点,因为我的扫描仪只会使用一个csproj(总是一样)

这是我使用命令行的方式

E:\SonarQube\bin\SonarQube.Scanner.MSBuild.exe  begin /k:"MySuperProjectKey" /n:"MySuperName" /v:"1.0"

然后我正在使用msbuild工具进行构建(不涉及Visual Studio)

'"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe" /t:Rebuild  /p:Configuration=dev MySuperVSProjectWithPlentyOfCSPROJ.sln"'

然后正常结束

"E:\SonarQube\bin\SonarQube.Scanner.MSBuild.exe end"

最终,在我的SonarQube网站上分析的C#共享库项目只有一个,而不是10个或更多。

2 个答案:

答案 0 :(得分:0)

我必须使用SonarScanner.MSBuild.exe而不是SonarQube.Scanner.MSBuild.exe 我所有的csproj现在都在我的仪表板上。

答案 1 :(得分:0)

您可以从声纳扫描中排除不必要的csproj文件。以下内容可能对您有所帮助

 <!-- in .csproj -->
 <PropertyGroup>
 <!-- Exclude the project from analysis -->
 <SonarQubeExclude>true</SonarQubeExclude>
 </PropertyGroup>