title: How to publish Cobertura coverage report from the VS coverage produced by dotnet test --collect "Code coverage"?
body: <p>So the process can be deduced from <a href="https://docs.microsoft.com/en-us/azure/devops/pipelines/ecosystems/dotnet-core?view=azure-devops#collect-code-coverage" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/azure/devops/pipelines/ecosystems/dotnet-core?view=azure-devops#collect-code-coverage</a> and contains of the following steps:</p>
  
  <ol>
  <li>Run the tests with coverage <strong>without</strong> publishing the test results, because we need to control the location of the generated binary coverage report (see <a href="https://stackoverflow.com/questions/61089491/how-to-set-a-custom-coverage-result-file-path-when-running-dotnet-test-collect/61091018?noredirect=1#comment108158087_61091018">How to set a custom coverage result file path when running dotnet test --collect &quot;Code coverage&quot;?</a>)</li>
  <li>Convert the VS binary coverage result to XML</li>
  <li>Install the reportgenerator tool</li>
  <li>Convert the VS XML coverage to Cobertura using the reportgenerator tool</li>
  <li>Publish the Cobertura report using the Publish Code Coverage Azure DevOps task</li>
  <li>Publish the Test Results</li>
  </ol>
  
  <p>These steps can be implemented with the following YAML template:</p>
  
  <pre><code>parameters:
    BuildConfiguration: Debug
  
  steps:
  - task: DotNetCoreCLI@2
    name: Test
    displayName: Test
    inputs:
      command: 'test'
      publishTestResults: false
      arguments: '-c ${{ parameters.BuildConfiguration }} --no-build -l trx -r $(Common.TestResultsDirectory)\tests --collect "Code coverage"'
  
  - task: PublishTestResults@2
    displayName: Publish Test Results
    inputs:
      testResultsFormat: VSTest
      testResultsFiles: '*.trx'
      searchFolder: $(Common.TestResultsDirectory)\tests
      testRunTitle: $(Build.DefinitionName)-$(Build.BuildNumber)
    condition: succeededOrFailed()
  
  - powershell: |
      $cc = "$(Get-ToolFolderFromNuGet Microsoft.CodeCoverage)\..\build\netstandard1.0\CodeCoverage\CodeCoverage.exe"
      $BinaryCoverageFile = (Get-Item "$(Common.TestResultsDirectory)\tests\*\*.coverage").FullName
      &amp; $cc analyze /output:$(Common.TestResultsDirectory)\vstest-coverage.xml $BinaryCoverageFile
    displayName: Convert Coverage Result To Xml
  
  - task: DotNetCoreCLI@2
    inputs:
      command: custom
      custom: tool
      arguments: install --tool-path . dotnet-reportgenerator-globaltool
    displayName: Install ReportGenerator tool
  
  - script: .\reportgenerator.exe -reports:$(Common.TestResultsDirectory)\vstest-coverage.xml -targetdir:$(Common.TestResultsDirectory)\coverage\report -reporttypes:"Cobertura"
    displayName: Create Cobertura Coverage Report
  
  - task: PublishCodeCoverageResults@1
    displayName: Publish Coverage Results
    inputs:
      codeCoverageTool: 'Cobertura'
      summaryFileLocation: '$(Common.TestResultsDirectory)/coverage/report/Cobertura.xml'
      failIfCoverageEmpty: true
  </code></pre>
  
  <p>It uses my powershell function <code>Get-ToolFolderFromNuGet</code> to download a package from NuGet, but other than that no custom code is used.</p>
  
  <p>Anyway, the problem is that the Publish Test Results task publishes the binary coverage result as a hyperlink in the same tab where the coverage results are supposed to be:</p>
  
  <p><a href="https://i.stack.imgur.com/hKF05.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hKF05.png" alt="enter image description here"></a></p>
  
  <p>This is useless. If I comment out the Publish Test Results, the coverage page shows the expected result:</p>
  
  <p><a href="https://i.stack.imgur.com/gRTrx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gRTrx.png" alt="enter image description here"></a></p>
  
  <p>But now I lost the Tests page, of course:</p>
  
  <p><a href="https://i.stack.imgur.com/AvwsF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AvwsF.png" alt="enter image description here"></a></p>
  
  <p>Does anyone know how to resolve this conundrum?</p>
  
  <p>P.S.</p>
  
  <p>I opened a bug here - <a href="https://github.com/microsoft/azure-pipelines-tasks/issues/12670" rel="nofollow noreferrer">https://github.com/microsoft/azure-pipelines-tasks/issues/12670</a></p>
  
  <p><strong>EDIT 1</strong></p>
  
  <p>I tried to Publish the Test Results at the end and even deleting the binary coverage result file. Nothing helps.</p>