Coverage does not appear

Hello, I have a problem coverage does not appear. However, the .trx and Cobertura.xml files are created correctly. Why does my process look the way it does? The first machine can run integration tests with the database (but send sonar is blocked in this machine), and the second machine has no access to the database in the company network but is in Azure, and it is possible to connect to sonar. The second machine downloads the test results from the artifacts, and the files are downloaded. However, coverage does not appear in the sonar cloud.

The worst part is that it looks good and should work. :frowning:

# .NET Desktop
# Build and run tests for .NET Desktop or Windows classic desktop solutions.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/apps/windows/dot-net

trigger:
- master
- develop


stages:
- stage: build
  jobs:
  - job: A
  
    pool:
      name: 'On-site pipelines'
      demands: Dotnet.Version -equals 6.0.0
    
    variables:
      configuration: release
      npm_config_cache: $(Pipeline.Workspace)/.npm
      SolutionDir: '..\.\'
    
    steps:
    - task: DotNetCoreCLI@2
      displayName: Restore NuGet Packages
      inputs:
        command: 'restore'
        projects: '**/*.csproj'
        feedsToUse: 'config'
        nugetConfigPath: './nuget.config'
        
    - task: NuGetToolInstaller@1
      inputs:
        versionSpec: 
        checkLatest: true
    
    - task: DotNetCoreCLI@2
      displayName: Build .Net Core Projects
      inputs:
        command: 'build'
        projects: |
          **/*.csproj
        arguments: '--runtime win-x64'
    
    - task: DotNetCoreCLI@2
      displayName: Run Tests
      inputs:
        command: 'test'
        projects: '**/*.Tests*.csproj'
        nobuild: true
        arguments: '--configuration $(configuration) --collect:"Code Coverage" /p:Exclude="[*Tests*]*"'

    - task: DotNetCoreCLI@2
      displayName: "dotnet test"
      inputs:
        command: 'test'
        projects: 'Backend\App\App.sln'
        publishTestResults: true
        arguments: --no-restore --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura

    - task: reportgenerator@4
      displayName: "Merge code coverage reports"
      inputs:
        reports: "**/coverage.cobertura.xml"
        targetdir: "$(Build.ArtifactStagingDirectory)/coverlet"
        reporttypes: "Cobertura"
        verbosity: "Verbose"
      
    - task: PublishPipelineArtifact@1
      displayName: Publish Artifacts from output folder
      inputs:
        targetPath: '$(Build.ArtifactStagingDirectory)/coverlet'
        artifact: 'Cobertura'
        publishLocation: 'pipeline'
    
    - task: PublishPipelineArtifact@1
      displayName: Publish Artifacts for sonar
      inputs:
        targetPath: 'F:\agent\_temp\'
        artifact: 'AIDA_SONAR_TRX'
        publishLocation: 'pipeline'
 
- stage: build_sonar
  jobs:
  - job: B
  
    pool:
     vmImage: 'windows-latest'
    
    variables:
      configuration: release
      npm_config_cache: $(Pipeline.Workspace)/.npm
      SolutionDir: '..\.\'
      
    steps: 
    - task: NuGetToolInstaller@1
      inputs:
        versionSpec: 6.0.0
        
    - task: DownloadPipelineArtifact@2
      inputs:
        buildType: 'current'
        artifactName: 'AIDA_SONAR_TRX'
        targetPath: 'D:/a/_temp'
    
    - task: DownloadPipelineArtifact@2
      inputs:
        buildType: 'current'
        artifactName: 'Cobertura'
        targetPath: 'D:/a/_temp' 
        
    - task: DotNetCoreCLI@2
      displayName: Restore NuGet Packages
      inputs:
        command: 'restore'
        projects: |
          **/Connectors.App.csproj
        feedsToUse: 'config'
        nugetConfigPath: './nuget.config'
        
    - task: SonarCloudPrepare@1
      displayName: 'Prepare SonarCloud analysis'
      inputs:
        SonarCloud: 'XXX'
        organization: 'XXX'
        scannerMode: 'MSBuild'
        projectKey: 'XXX'
        projectName: 'XXX'
        extraProperties: |
            sonar.cs.cobertura.reportsPaths=D:\a\_temp\Cobertura.xml
            sonar.cs.vstest.reportsPaths=D:\a\_temp\*.trx
          
    - task: DotNetCoreCLI@2
      displayName: Build .Net Core Projects
      inputs:
        command: 'build'
        projects: |
          **/*.csproj
        arguments: '--runtime win-x64 --no-restore --self-contained false'
         
    - task: CopyFiles@2
      displayName: Copy backend build files to output folder
      inputs:
        SourceFolder: '$(Build.SourcesDirectory)/Backend/App/RuntimeWeb'
        Contents: '**'
        TargetFolder: '$(Build.SourcesDirectory)/build/Backend'
        
    - task: SonarCloudAnalyze@1
      displayName: 'Run SonarCloud code analysis'
    
    - task: SonarCloudPublish@1
      displayName: 'Publish SonarCloud quality gate results'
      inputs:
        pollingTimeoutSec: '300'


Hi,

sonar.cs.cobertura.reportsPaths isn’t a recognized parameter.

Regarding your analysis logs, it looks like you’ve shared a screenshot of logs – and nobody in this Community likes to pretend they’re an optical character reader.

If your question isn’t answered, can you please share the text of your logs?

 
Ann

logs.txt (28.2 KB)

it`s not resolve my problem I added logs

Hi,

I see a lot of coverage reports being found

2022-12-29T21:45:58.2925060Z Property 'sonar.cs.vstest.reportsPaths' provided, skipping the search for TRX files in default folders...
2022-12-29T21:45:58.3760727Z Did not find any binary coverage files in the expected location.
2022-12-29T21:45:58.3774259Z Falling back on locating coverage files in the agent temp directory.
2022-12-29T21:45:58.3779200Z Searching for coverage files in D:\a\_temp
2022-12-29T21:45:58.3839687Z All matching files: count=16
2022-12-29T21:45:58.3840912Z 	D:\a\_temp\0e9fd580-466b-45ce-8d0e-4bcf90c269c3\testBuild_PL-W-7347028_2022-12-29.22_31_14.coverage
2022-12-29T21:45:58.3841997Z 	D:\a\_temp\4ff8d1c8-b904-4a98-bffa-d5545e4a7f39\testBuild_PL-W-7347028_2022-12-29.22_33_21.coverage
2022-12-29T21:45:58.3843650Z 	D:\a\_temp\5828f17c-8257-4f2f-b8cb-b9a0c0014f2f\testBuild_PL-W-7347028_2022-12-29.22_32_08.coverage
...

and parsed

2022-12-29T21:47:30.9982580Z INFO: Sensor C# Tests Coverage Report Import [csharp]
2022-12-29T21:47:30.9999587Z INFO: Parsing the Visual Studio coverage XML report D:\a\_temp\0e9fd580-466b-45ce-8d0e-4bcf90c269c3\testBuild_PL-W-7347028_2022-12-29.22_31_14.coveragexml
2022-12-29T21:47:43.4002062Z INFO: Adding this code coverage report to the cache for later reuse: D:\a\_temp\0e9fd580-466b-45ce-8d0e-4bcf90c269c3\testBuild_PL-W-7347028_2022-12-29.22_31_14.coveragexml
2022-12-29T21:47:43.4004020Z INFO: Parsing the Visual Studio coverage XML report D:\a\_temp\4ff8d1c8-b904-4a98-bffa-d5545e4a7f39\testBuild_PL-W-7347028_2022-12-29.22_33_21.coveragexml
2022-12-29T21:47:58.4738130Z INFO: Adding this code coverage report to the cache for later reuse: D:\a\_temp\4ff8d1c8-b904-4a98-bffa-d5545e4a7f39\testBuild_PL-W-7347028_2022-12-29.22_33_21.coveragexml
2022-12-29T21:47:58.4739337Z INFO: Parsing the Visual Studio coverage XML report D:\a\_temp\5828f17c-8257-4f2f-b8cb-b9a0c0014f2f\testBuild_PL-W-7347028_2022-12-29.22_32_08.coveragexml
...

Looking back at your OP

You’re producing the coverage reports on a different machine than analysis is run on? Do the file paths on the machines match? Because if the coverage reports are about files at D:\foo... but analysis is handling files at C:\foo... then analysis won’t recognize the coverage reports as being about the files its processing.

 
Ann