【问题标题】:How to exclude single files when using MSBuild Scanner使用 MSBuild Scanner 时如何排除单个文件
【发布时间】:2017-05-31 04:08:40
【问题描述】:

我们正在使用适用于 MSBuild (1.1.0.0) 的 SonarQube 扫描仪,并且有一个包含多个项目的解决方案。

在我们提供给扫描仪 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 Scanner 时,从覆盖范围和源代码分析中排除整个目录的推荐方法是什么?

【问题讨论】:

    标签: sonarqube sonarqube-scan


    【解决方案1】:

    尝试将排除项放在项目文件 (.csproj) 本身中,例如:

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

    Appendix 2: Configuring the SonarQube Scanner for MSBuild

    【讨论】:

    • 谢谢。这可能有效,但我不喜欢将 SonarQube 关联设置放入我的项目文件中。
    猜你喜欢
    • 2018-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-19
    • 2019-03-29
    • 1970-01-01
    相关资源
    最近更新 更多