We are using the SonarQube Scanner for MSBuild (1.1.0.0) and have a solution containing multiple projects.
There is a SonarQube.Analysis.xml
in the solution root folder which we supply to the scanners cli.
<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>
Now the problem is: Project1/Migrations/*
seems not to get excluded because the Base dir
is set to .../Project1
during the scan. The same happens for all other projects in the solution. The result is that .../Project1/Project1/Migrations/*
is an unknown path.
So what is the recommended way to exclude a whole directory from coverage and sourcecode analytics when using MSBuild Scanner?
Try to put the exclusions in the project file (.csproj) itself, something like:
<ItemGroup>
<SonarQubeSetting Include="sonar.exclusions">
<Value>**/Migrations/*</Value>
</SonarQubeSetting>
</ItemGroup>
See Appendix 2: Configuring the SonarQube Scanner for MSBuild.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With