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
After trying a thousand things I finally found the solution. It's necessary to add an item group in the .csproj.
true