Sonarqube allows for individual files to be excluded from code coverage by adding patterns in the sonar.coverage.exclusions key. This can be done on a project level by
I had the same problem, and it took me a while to figure it out:
Set up a Directory.Build.props file in the solution directory with this content:
true
true
This fragment will be included in all project files as explained here https://docs.microsoft.com/en-us/visualstudio/msbuild/customize-your-build
Set the regex in the environment variable SQExclusionFilter accordingly. Use double-backslashes for path separation. In windows shell escape pipe characters with a caret: e.g.
set SQExclusionFilter=(path1\\project)^|(path2\\project)
Credits to Duncan Pocklington from SQ/MS!