Coverage Report is not generating in sonar

Hi Team,

-I’m facing an issue while trying to import Visual Studio coverage into SonarQube during Azure DevOps pipeline execution.

-Scanner**: Azure DevOps SonarQubePrepare@7 / SonarScanner for MSBuild
-Build agent OS: Windows-2019
-Language**: C#
-Project Type**: .NET Framework (not .NET Core)
-Coverage Tool**: Visual Studio’s CodeCoverage.exe (converted .coverage to .coveragexml)

-Problem Details:

-My pipeline generates .coveragexml successfully.
-I pass the path in extraProperties of SonarQubePrepare like:
-extraProperties: |

sonar.cs.vscoveragexml.reportsPaths=$(Build.ArtifactStagingDirectory)\CoverageXmlDebug***.coveragexml.

-During analysis, I see the file is found and parsed:

INFO: Parsing the Visual Studio coverage XML report D:\a\1\a\TestResults\...\*.coveragexml

-BUT:
WARN: The Code Coverage report doesn't contain any coverage data for the included files.

-Troubleshooting already done:

  • .pdb files are present during test run and coverage generation.
  • Coverage is generated after test execution, before SonarQubeAnalyze.
  • Build is done with /p:DebugType=full /p:DebugSymbols=true.
  • No manual deletion of .pdb files before coverage.
  • .coveragexml path matches the source files path reported by Sonar scanner (D:\a\1\s\).
  • .coveragexml file opens correctly in Visual Studio.

Hi,

Could you provide a debug analysis log?

Share the Scanner for .NET verbose logs

  • Add /d:"sonar.verbose=true" to the…
    • SonarScanner.MSBuild.exe or dotnet sonarscanner begin command to get more detailed logs
      • For example: SonarScanner.MSBuild.exe begin /k:"MyProject" /d:"sonar.verbose=true"
    • “SonarQubePrepare” or “SonarCloudPrepare” task’s extraProperties argument if you are using Azure DevOps
      • For example:
        - task: SonarCloudPrepare@3
            inputs:
              SonarCloud: 'sonarcloud'
              organization: 'foo'
              scannerMode: 'dotnet'
              projectKey: 'foo_sonar-scanning-someconsoleapp'
              projectName: 'sonar-scanning-someconsoleapp'
              extraProperties: |
                sonar.verbose=true
        
  • The important logs are in the END step (i.e. SonarQubeAnalyze / SonarCloudAnalyze / “Run Code Analysis”)

Share the msbuild detailed logs

MsBuild.exe /t:Rebuild /v:d

or

dotnet build -v:d

 
Thx,
Ann

HI so the soultion which you have provided, we have already implemented,

  • task: SonarQubePrepare@7
    inputs:
    SonarQube: ‘Sonarqube’
    scannerMode: ‘dotnet’
    projectKey: ‘ProjectKey(This for demo)’
    projectName: ‘ProjectName(This for demo)’
    projectVersion: ‘$(version)’
    extraProperties: |
    sonar.cs.vscoveragexml.reportsPaths=D:/a/_temp/TestResults/*.coveragexml
    sonar.verbose= true

if any thing else you want feel free to ask.

Hi,

As described in my previous post, please share the copy/pasted text of the end step logs.

 
Thx,
Ann