2017-01-16 41 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