Hi I have an Azure DevOps pipeline that I can’t seem to get the code coverage into SonarCloud to work at all.
Here is the sections of the yml file that I’ve setup
- task: SonarCloudPrepare@1 inputs: SonarCloud: 'SonarCloud Service Connection' organization: 'xx' scannerMode: 'MSBuild' projectKey: 'xx' projectName: 'xx' projectVersion: 'sonar.projectVersion' extraProperties: | sonar.exclusions=**/obj/**,**/*.dll sonar.opencover.reportPaths=$(Build.SourcesDirectory)/TestResults/Coverage/coverage.cobertura.xm ... script: dotnet test Functions/xx/xx.sln /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=$(Build.SourcesDirectory)/TestResults/Coverage/ displayName: Run Unit Tests - $(buildConfiguration) - task: DotNetCoreCLI@2 displayName: Install ReportGenerator Global Tool inputs: command: custom custom: tool arguments: install dotnet-reportgenerator-globaltool -g - script: echo "##vso[task.prependpath]$HOME/.dotnet/tools" displayName: 'Add ReportGenerator to PATH' - script: reportgenerator "-reports:$(Build.SourcesDirectory)/TestResults/Coverage/coverage.cobertura.xml" "-targetDir:$(Build.SourcesDirectory)/TestResults/Coverage/Reports" "-tag:$(Build.BuildNumber)" "-reportTypes:HtmlInline_AzurePipelines;Cobertura" displayName: 'Generate HTML Coverage Report' - task: SonarCloudAnalyze@1 - task: SonarCloudPublish@1 inputs: pollingTimeoutSec: '300' - task: PublishCodeCoverageResults@1 displayName: 'Publish Code Coverage' inputs: codeCoverageTool: Cobertura summaryFileLocation: '$(Build.SourcesDirectory)/TestResults/Coverage/coverage.cobertura.xml' reportDirectory: '$(Build.SourcesDirectory)/TestResults/Coverage/Reports'
My test project has references to coverlet.msbuild (3.1.2) as was suggested as a solution on another post, but nothing seems to be working for me, Sonar cloud is just showing 0% but I know from the reports that are getting generated in the pipeline that the coverage is higher. I can see the coverage.cobertura.xml file in the artifacts as well so it is getting generated.
In the logs for the SonorCloudAnalyze I can’t find any reference to the file coverage.cobertura.xml, not a file not found or incorrect format message or anything.
Any help or pointers on what to try on this one is appreciated as it’s been driving me insane now for for too long.