Azure Devops SonarCloud Yaml Pipeline Code Coverage

We are currently trying to get the code coverage to work with our analysis, unfortunately despite my best efforts something is not configured quite right:

Calling the TFS Processor executable...
Property 'sonar.cs.vstest.reportsPaths' provided, skipping the search for TRX files in default folders...
Did not find any binary coverage files in the expected location.
Falling back on locating coverage files in the agent temp directory.
Searching for coverage files in D:\Agents\Agent-1\_work\_temp
No coverage files found in the agent temp directory.
Coverage report conversion completed successfully.
The TFS Processor has finished
Calling the SonarScanner CLI...

This is our current pipeline:

name: ###-Prebuild-and-Unit-Testing$(date:yyyyMMdd)$(rev:.r)

trigger:
  branches:
    include:
      - main
      - release/*
  paths:
    exclude:
      - ReleaseNotes/*

pool:
  name: 'Default'
  
variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'


stages:
  - stage: UnitTests
    displayName: "PreBuild, Unit Tests"
    jobs:
      - job:
        displayName: "### Prebuild and Unit Testing"
        timeoutInMinutes: 180
        steps:
          - task: DotNetCoreCLI@2
            displayName: "DotNet Restore"
            inputs:
              command: 'restore'
              projects: '$(solution)'
              feedsToUse: 'select'
          - task: SonarCloudPrepare@3.1.1
            displayName: Prepare analysis configuration
            inputs:
              SonarQube: 'SonarCloud'
              organization: '###'
              scannerMode: 'dotnet'
              projectKey: '###-backend'
              projectName: '###-backend'
              extraProperties: |
                sonar.exclusions=**/obj/**,**/*.dll,**/*.sql,**/bin/**,**/*.xml,**/###.Data/**,**/lib/**
                sonar.cs.opencover.reportsPaths=$(Agent.TempDirectory)/**/coverage.opencover.xml
                sonar.cs.vstest.reportsPaths=$(Agent.TempDirectory)/*.trx
            enabled: true
          - task: DotNetCoreCLI@2
            displayName: "DotNet Build"
            inputs:
              command: 'build'
              projects: '$(solution)'
              arguments: '-c $(buildConfiguration) --source https://api.nuget.org/v3/index.json'
          - task: DotNetCoreCLI@2
            displayName: "DotNet Test"
            continueOnError: true
            inputs:
              command: test
              projects: '**/*.Test/*.csproj'
              arguments: '--configuration $(buildConfiguration) /p:CollectCoverage=true /p:CoverletOutputFormat=opencover --logger trx'
          - task: SonarCloudAnalyze@3.1.1
            displayName: SonarCloud - Run code analysis
          - task: SonarCloudPublish@3.1.1
            displayName: SonarCloud - Publish quality gate result
            inputs:
              pollingTimeoutSec: '300'

Thank you for your time.

Hi,

You’re using a wildcard here, but that’s not listed in the docs as being supported. You’ll need to provide full paths.

 
HTH,
Ann

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