Azure Devops task no coverage values pushed SonarCloud

  • ALM used : Azure DevOps
  • CI system used : Azure DevOps
  • Scanner command used when applicable (private details masked)

Task from pipe :

  • task: SonarCloudPrepare@1
    displayName: ‘Sonar -Code Analysis - Begin (PR)’
    condition: eq(variables[‘Build.Reason’], ‘PullRequest’)
    inputs:
    SonarCloud: $(sonar.cloud)
    organization: $(sonar.organization)
    scannerMode: ‘MSBuild’
    projectKey: $(sonar.projectKey)
    projectName: $(sonar.projectName)
    projectVersion: $(sonar.projectVersion)
    extraProperties: |
    sonar.cs.opencover.reportsPaths=${{parameters.workingDirectory}}\reports*.coverage.openCover.xml
    sonar.analysis.buildNumber=$(Build.BuildId)
    sonar.analysis.pipeline=$(Build.BuildId)
    sonar.analysis.sha1=$(System.PullRequest.SourceCommitId)
    sonar.analysis.prNumber=$(System.PullRequest.PullRequestNumber)
    sonar.analysis.repository=$(Build.Repository.ID)
    sonar.exclusions = **/*.sql
  • Languages of the repository : C#
  • Error observed :
    Some coverage are converted other are skipped, but no coverage in Sonar :

Debug from auree devops SonarCloudAnalyze@1 task :
22:19:57.041 INFO: Parsing the OpenCover report D:\a\1\s\Src_.coverage.openCover.xml
22:19:57.042 DEBUG: CoveredFile created: (ID ‘1’, path '
.cs’, indexed as ‘.cs’).
.
.
.
22:19:57.114 DEBUG: Skipping ‘____.cs’ as it is a test file.
22:19:57.114 DEBUG: Skipping '
.cs’ as it is a test file.
.
.

22:19:57.114 DEBUG: The total number of file count statistics is ‘182’.
22:19:57.115 INFO: Coverage Report Statistics: 182 files, 0 main files, 0 main files with coverage, 182 test files, 0 project excluded files, 0 other language files.

22:19:57.115 WARN: The Code Coverage report doesn’t contain any coverage data for the included files. Troubleshooting guide: [Coverage] Troubleshooting guide for .NET code coverage import

But from other hand i have this report with Azure devops PR reports (generated with Cobertura):

*.coverage.openCover.xml are pushed Azure devops and give this report :

  • Steps to reproduce

Hi @Haithem,

Welcome to our community forum. This line from your logs suggests that your project is classified as a test project and coverage is not imported for test projects.

Please make sure that your production code project is not classified as test project, for example by marking it as <SonarQubeTestProject>False</SonarQubeTestProject>. You can find more information about test project detection here:

Hello @Pavel_Mikula
Thank you for your reactivity, i have resolved the problem by improving the quality of my original report sended to Sonar, OpenCover was only generating coverage on tests files.

Thank you.
Haithem

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.