2
votes

We have a Visual Studio solution containing 10+ projects including ASP.NET Web project. Created a Jenkins Jobs and configured with SonarQube to show code coverage metrics, and the job runs successfully.

When tried to narrow down the focus while calculating code coverage metrics (excluding ASP.NET Web Projects) using the below argument then getting an error-

sonar.exclusions="\ASP.NET PROJECT NAME*"

Error- Unrecognized command line argument: sonar.exclusions=\*

Already referred Narrowing the Focus and Excluding projects from the MSBuild Runner without changing csproj files

Could anyone please suggest with actual syntax- how to exclude projects from 'SonarQube Scanner for MSBuild- Begin Analysis’ plugin in Jenkins

Thanks!! Any lead is much appreciated

1

1 Answers

7
votes

Try with /d:sonar.exclusions=<value>. The text box in Jenkins expects command line arguments for Scanner for MSBuild, which are in the form /d:<sonar.property>=<value>.

The sonar.exclusions property is not very intuitive, because the filter is applied separately for each project and is relative to the project root, not the solution root (and you cannot use .. to go back to the solution)...

Perhaps a better option to exclude a single project from analysis is to put the following within the .csproj file itself:

<PropertyGroup> <!-- Exclude the project from analysis --> <SonarQubeExclude>true</SonarQubeExclude> </PropertyGroup>