1

enter image description hereI am trying to exclude some folders from Sonar scan through VSTS build. We have used Sonar plugin for MSBuild.

If I use the exclusion pattern as **/*.cs then it is excluding all the .cs files. My goal is to exclude whole folder from scan. I have tried the following patterns but none of them seems to work

**/folder/*
**/folder/*.cs
**/folder/**
**/folder/**/*
**/folder/**/*.cs
folder/*.cs
folder/**/*.cs
folder/**/*
folder/**
folder/*

Please help in getting the correct pattern.

I want to exclude This Issue project from the scan.

Shubh Rocks Goel
  • 519
  • 1
  • 6
  • 17
  • 1
    `folder/**` or `**/folder/**` should work without a problem. Remember, that the root directory is the one with *.csproj file. Maybe try to edit your post and show us your folder structure + what you have in SonarQube. – Peska Jun 26 '18 at 17:22
  • Your suggestion is correct that the root directory is *.csproj. DO you know how to exclude any project from the analysis or how o exclude an entire csproj file from scan so that not files inside that project get scanned? – Shubh Rocks Goel Jun 27 '18 at 11:31
  • There is partial solution to this problem in this question: https://stackoverflow.com/questions/49816611/sonarqube-msbuild-scanner-doesnt-exclude-files-from-analysis – Peska Jun 27 '18 at 12:53

1 Answers1

2

You can exclude an entire C# project by setting the MSBuild property SonarQubeExclude to true in the project file. See this post: How to exclude/ignore referenced project(s) analysis from SoanrQube

duncanp
  • 1,572
  • 1
  • 10
  • 8
  • This solution anyhow works, but this will also include a time effort to implement and in our problem we have multiple builds for same solution. In some of them do not need sonar on solution x but in some we need. So if there is something that we can implement through Sonar server side then it would be better. – Shubh Rocks Goel Jun 28 '18 at 09:59