How to exclude individual files when using MSBuild Scanner

We use the SonarQube Scanner for MSBuild (1.1.0.0) and have a solution containing several projects.

In the root folder of the solution is SonarQube.Analysis.xml , which we supply to cli scanners.

 <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: Project1/Migrations/* does not seem to be ruled out, because during the scan, Base dir set to .../Project1 . The same thing happens for all other projects in the solution. As a result .../Project1/Project1/Migrations/* is an unknown path.

So, what is the recommended way to exclude a whole directory from the scope and analysis of the source code when using MSBuild Scanner?

+5
source share
1 answer

Try putting exceptions in a project file (.csproj), something like:

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

See Appendix 2: Configuring the SonarQube Scanner for MSBuild .

+2
source

Source: https://habr.com/ru/post/1262867/


All Articles