Sonarcloud issues for dotnet project

I have unit and integration test cases defined in multiple folders for which iam generating mutliple open cover xml files using below :
dotnet test “$proj” \

              --logger trx \\

               --results-directory "$(System.DefaultWorkingDirectory)/TestResults" \\

              /p:CollectCoverage=true \\

              /p:CoverletOutputFormat=opencover \\

              /p:CoverletOutput="$(System.DefaultWorkingDirectory)/TestResults/coverage/$name.coverage.xml"

      done

it is generating the files in /TestResults/, when i publish them for sonar analysis using below :

  - task: SonarCloudPrepare@3

    displayName: 'Prepare SonarCloud Analysis'

    inputs:

      SonarCloud: ${{ parameters.sonarConnection }}

      organization: ${{ parameters.organization }}

      scannerMode: 'dotnet'

      projectKey: ${{ parameters.projectKey }}

      projectName: ${{ parameters.projectName }}

      extraProperties: |

          sonar.exclusions=\*\*/bin/\*\*,\*\*/obj/\*\*

          sonar.test.inclusions=\*\*/\*.Tests/\*.cs

          sonar.cs.opencover.reportsPaths=$(System.DefaultWorkingDirectory)/TestResults/coverage/\*\*/\*.xml

iam suspecting all the reports are not being recognized by sonar, not seeing coverage for all my folders in src.. please advice

Hey there.

What do the logs say about importing code coverage?

Hey Colin, Thanks for taking a look into this. sonar analysis is running on all the generated coverage files..
but seeing below while parsing them.. this could the reason why all the folders in src are not showing up ?

2025-10-22T06:50:22.7337449Z 06:50:22.733 DEBUG: The file ‘/home/vsts/work/1/s/src/module1/testfile1.cs’ does not have a deterministic build path and is either not indexed or does not have a supported language. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.

Could be! There are similar reports in this community. Have a look through them and how they solved it:

Thanks Colin, this helped me. the issue was resolved but how can we pass cobertura.xml files to the sonarcloud for analysis? just like we did for open cover.. i want to move from opencover to cobertura for generating allure report purposes and other compatibilities

SonarQube doesn’t support Cobertura for coverage import on .NET. You can find the full list of supported formats (per language) here.

Hi @jchada-nb,

FYI, we are considering adding Cobertura support, but we do not have a firm timeline yet. You can see the feature, vote for it and register for updates on the public SonarQube Cloud Roadmap!

In the meantime I have recorded your need in our internal tool.

Thank you for your input and participation in the Community!

Denis

1 Like