2017-01-16 37 views
5

我们使用MSBuild(1.1.0.0)的SonarQube扫描仪,并且有一个包含多个项目的解决方案。如何在使用MSBuild扫描仪时排除单个文件

我们提供给扫描仪cli的解决方案根文件夹中有一个SonarQube.Analysis.xml。现在

<SonarQubeAnalysisProperties xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.sonarsource.com/msbuild/integration/2015/1"> 
    <Property Name="sonar.cs.opencover.reportsPaths">output/nunit-coverage.xml</Property> 
    <Property Name="sonar.cs.nunit.reportsPaths">output/nunit-result.xml</Property> 

    <Property Name="sonar.exclusions">Project1/Migrations/*</Property> 
    <Property Name="sonar.coverage.exclusions">Project1/Migrations/*</Property> 
</SonarQubeAnalysisProperties> 

的问题是:Project1/Migrations/*似乎并没有得到排除,因为Base dir是在扫描期间设置为.../Project1。解决方案中的所有其他项目也是如此。结果是.../Project1/Project1/Migrations/*是未知的路径。

那么当使用MSBuild扫描仪时,推荐的方法是从覆盖范围和源代码分析中排除整个目录?

回答

2

尽量把排除在项目文件(.csproj)本身,是这样的:

<ItemGroup> 
    <SonarQubeSetting Include="sonar.exclusions"> 
      <Value>**/Migrations/*</Value> 
    </SonarQubeSetting> 
</ItemGroup> 

Appendix 2: Configuring the SonarQube Scanner for MSBuild

+0

谢谢。这可能会奏效,但我不想将SonarQube相关设置放入我的项目文件中。 – philipooo