目前我有一个带有 C# 插件和 MSBuild 运行器的 SonarQube 5.1.2 实例,以便分析 1.200.000 LOC 项目.我打算减少要分析的类,我创建了一个带有
Currently I have an instance of SonarQube 5.1.2 with C# plugin and MSBuild runner in order to analyze a 1.200.000 LOC project. I intend to reduce the classes that are analyzed, I created a sonar.properties file with the line
sonar.exclusions=**/Databases/**/*.*
但是在从分析中读取日志后,Databases 文件夹中的文件被分析了.按照 Eric Starr 的说明,我设置了runner 调用中的这个简单的排除规则:
but after reading the log from the analysis, files inside the Databases folder were analyzed. following the instructions from Eric Starr, I set this simple exclusion rule in the call of the runner:
"C:sonarqube-5.1.2inMSBuild.SonarQube.Runner.exe" begin /k:MyProject /n:MyProject /v:2 /d:sonar.exclusions="file:C:codesourceDatabases/**/*.*" /d:sonar.scm.provider=tfvc /d:sonar.tfvc.username=************* /d:sonar.tfvc.password.secured={aes}*************************** "/d:sonar.cs.vscoveragexml.reportsPaths=C:codesourceCodeCoverageResults.coveragexml"
我发现跑步者创建了一个 sonar-project.properties 文件,它包含很多位于数据库文件夹中的文件:
I found that the runner creates a sonar-project.properties file, and it contains a lot of files located in the databases folder:
BC78C8C4-8ECD-47CB-9781-F621AE109FE4.sonar.projectName=myDatabase
BC78C8C4-8ECD-47CB-9781-F621AE109FE4.sonar.projectBaseDir=BC78C8C4-8ECD-47CB-9781-F621AE109FE4.sonar.projectName=myDatabase
BC78C8C4-8ECD-47CB-9781-F621AE109FE4.sonar.projectBaseDir=C:\codesource\Databases\myDatabase
BC78C8C4-8ECD-47CB-9781-F621AE109FE4.sonar.sources=
C:\codesource\Databases\myDatabase\Scripts\PreDeployment\PATCH_20150527_01.sql,
C:\codesource\Databases\myDatabase\Scripts\PreDeployment\ROCOMMON.DBVERSION.sql,
,.....
据我了解,数据库文件夹中应该没有文件.我错了吗?
as I understood, there should be no files in the databases folder. Am I wrong?
您正在使用 SonarQube Scanner for MSBuild 与常规 SonarQube 扫描仪有很大不同a> 用于所有其他语言.
You are using the SonarQube Scanner for MSBuild which is very different from the regular SonarQube Scanner used for all other languages.
您尝试使用的 sonar.exclude
行仅在您使用常规 SonarQube 扫描仪时才有效,因为它包含 Sonar-project.properties 文件.适用于 MSBuild 的 SonarQube 扫描仪只有一个 SonarQube.Analysis.Xml 文件,其中包含您可以调整的项目相关设置.
The sonar.exclude
line that you are trying to use would only work if you would use the regular SonarQube scanner, because that takes in the Sonar-project.properties file. The SonarQube Scanner for MSBuild only has a SonarQube.Analysis.Xml file that contains project-related settings that you can tweak.
您可以对 SonarQube.Analysis.Xml 文件使用几种覆盖策略:
You can use couple of overwriting strategies for the SonarQube.Analysis.Xml file:
要从您的解决方案中排除特定文件夹或扩展:
您需要将排除项添加到每个单独项目的 .csproj 文件中.这是您应该在主根节点中使用的语法,称为 <Project...>
并用于目标之一,最好是 <Target Name="BeforeBuild">代码>.希望下面的语法足够不言自明,但如果不是,请在此答案下发表评论,我会立即更新.
You need to add the excludes into each individual projects' .csproj file. Here's the syntax which you should use within the main root node, called <Project...>
and into one of the targets, preferably <Target Name="BeforeBuild">
. Hope the syntax below is self-explanetory enough, but in case it isn't, please leave a comment under this answer and I'll update it right away.
<Target Name="BeforeBuild">
<ItemGroup>
<SonarQubeSetting Include="sonar.exclusions">
<Value>**/Databases/**/*</Value>
</SonarQubeSetting>
</ItemGroup>
</Target>
希望对你有帮助!
来源
这篇关于带有 C# 插件和 MSBuild Runner 的 SonarQube 不会排除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!