Coverage exclusion not working

I’m trying to add two coverage exclusion rules and they work independently but not together. The first is intended to filter all files that end in “ControllerDocumentation.cs” and the second is intended to filter all files that fall under folders that start with “MyProject.Tests”. The config looks like:

sonar.coverage.exclusions="**/*ControllerDocumentation.cs, **/MyProject.Tests*/**/*"

Any advice?

Hi Alex, and sorry for the late reply,

did you manage to fix your problem? Looking quickly at your setting, this should be working fine.

What fixed it for me was using the web client for the configuration. However, I’d really like to be able to handle it as a part of my CI scripts so it could be version controlled. Would be happy to work with you to get that figured out.

How do you configure this property in your CI scripts? This must definitely be possible to achieve what you want Alex.

We’re using command line configuration. The only thing that’s special is we’re using Azure Pipelines. I haven’t tried running the console runner myself manually. The reason I don’t think Azure Pipelines is the issue is because if I just do one or the other pattern it works fine. I’m inferring that Azure Pipelines is transparently passing those values in but that may not be true.

The yaml definitions look something like:

  - task: SonarSource.sonarcloud.some-guid
    displayName: 'Prepare analysis on SonarCloud'
      SonarCloud: 'the_project'
      organization: the organization
      projectKey: theProjectKey
      projectName: TheProjectName
      extraProperties: |
        sonar.coverage.exclusions="**/*ControllerDocumentation.cs, **/MyProject.Tests*/**/*"

So if I understand well, the following works:


And this works too:


But not when you combine both, it that right?

Sorry for the delay response.

Yes. That’s it exactly. If I put them into 1 comma-delimited string then neither of them work.

@Alex_Denton, if you do this, does it work:


You mean removing the quotes? I’m pretty sure I tried that but I can give it a go when I’m back at my desk.

@Alex_Denton I’m facing the same challenge - had you found a solution?

Hi @Saeven, feel free to send me a Run Code Analysis task log in debug mode (i can send you a PM if you need to share it privately) so then i can have a look. Thanks !