# CodeCoverage no longer reported in SonarQube

**URL:** <https://community.sonarsource.com/t/codecoverage-no-longer-reported-in-sonarqube/116079>\
**Category:** SonarQube Server / Community Build\
**Tags:** azuredevops-services, dotnet, sonarqube, coverage\
**Created:** [May 27, 2024, 4:30pm UTC](https://community.sonarsource.com/t/codecoverage-no-longer-reported-in-sonarqube/116079 "2024-05-27T16:30:55Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![milbrandt](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/milbrandt/32/3726_2.png) [@milbrandt](https://community.sonarsource.com/u/milbrandt)\
**Post date:** [May 27, 2024, 4:30pm UTC](https://community.sonarsource.com/t/codecoverage-no-longer-reported-in-sonarqube/116079/1 "2024-05-27T16:30:55Z")

</div>

Must-share information (formatted with [Markdown](https://commonmark.org/help/)):

- which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension) 10.4
- how is SonarQube deployed: zip
- what are you trying to achieve: Reporting of code coverage to SonarQube
- what have you tried so far to achieve this

What was changed / updated:

- .NET SDK 8.0.200 to 8.0.300
- Visual Studio 2022 to 17.10.0
- Microsoft.NET.Test.Sdk from 17.9.0 to 17.10.0
- MSTest from 3.3.1 to 3.4.0
- SonarAnalyzer.CSharp 9.23.2.88755 to 9.25.1.91650

Build pipeline as such (azure-pipelines.yml) remaind unchanged.

In Azure Pipelines the code coverage is still displayed.

**Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!**

```auto

  Process id: 4100
Microsoft (R) Coverage Collection Tool Version 17.0.24162.516205

Copyright (c) Microsoft Corporation. All rights reserved.

CodeCoverage.exe is deprecated. Use dotnet-coverage global tool or Microsoft.CodeCoverage.Console instead. Some features of CodeCoverage.exe will be removed in next release of Visual Studio.

Usage: CodeCoverage <command>

Process returned exit code -1
Coverage report conversion completed successfully.
##[error]Failed to convert the binary code coverage reports to XML. No code coverage information will be uploaded to the server (SonarQube/SonarCloud).
Failed to convert the binary code coverage reports to XML. No code coverage information will be uploaded to the server (SonarQube/SonarCloud).
##[error]Check that the downloaded code coverage file (D:\_1\_temp\95187fae-3522-4760-a3c4-b83266de67a4\svc-buildtfs_SRVCS0000013_2024-05-27.13_22_51.coverage) is valid by opening it in Visual Studio. If it is not, check that the internet security settings on the build machine allow files to be downloaded from the Team Foundation Server machine.
Check that the downloaded code coverage file (D:\_1\_temp\95187fae-3522-4760-a3c4-b83266de67a4\svc-buildtfs_SRVCS0000013_2024-05-27.13_22_51.coverage) is valid by opening it in Visual Studio. If it is not, check that the internet security settings on the build machine allow files to be downloaded from the Team Foundation Server machine.
The TFS Processor has finished
Calling the SonarScanner CLI...

```

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [May 29, 2024, 7:28am UTC](https://community.sonarsource.com/t/codecoverage-no-longer-reported-in-sonarqube/116079/2 "2024-05-29T07:28:05Z")

</div>

Hey there.

> [@milbrandt](#):
>
> - Microsoft.NET.Test.Sdk from 17.9.0 to 17.10.0

What happens if you revert this? There happens to be a Github issue (posted 12 minutes ago) claiming that that code coverage is broken with 17.10.0.

> <https://github.com/microsoft/vstest/issues/5072>
>
> \## Description
> In our CI pipeline in Azure Devops (on premise), we use the late…st stable Visual Studio test platform (currently 17.10.0):
> Although CodeCoverage states:
> \`\`\`
> CodeCoverage.exe is deprecated. Use dotnet-coverage global tool or Microsoft.CodeCoverage.Console instead. Some features of CodeCoverage.exe will be removed in next release of Visual Studio.
> \`\`\`
> Azure Devops seems to use this tool. The code coverage is broken and does not represent proper coverage anymore.
> Another tool, that is using this tool, is Sonarqube (our code quality gateway).
> These errors appears:
> \`\`\`
> \##\[error\]Failed to convert the binary code coverage reports to XML. No code coverage information will be uploaded to the server (SonarQube/SonarCloud).
> \##\[error\]Check that the downloaded code coverage file (D:\\azagent-p\\A1\\\_work\\\_temp\\11e7728a-01e7-4ae5-a924-a480fa3e0087\\\<----\>\_2024-05-27.18\_12\_16.coverage) is valid by opening it in Visual Studio. If it is not, check that the internet security settings on the build machine allow files to be downloaded from the Team Foundation Server machine.
> \`\`\`
> and the gateway fails. This results in impossibility to merge code via pull requests, while the gateway is mandatory.
> Visual studio can interpret the coverage, but it doesn't represent the proper coverage.
> 
> \## Steps to reproduce
> Use the latest stable version in a CI pipeline
> \`\`\`
> displayName: 'Visual Studio Test Platform Installer'
> inputs:
> packageFeedSelector: 'nugetOrg'
> versionSelector: 'latestStable'
> \`\`\`
> and compare the code coverage against the same pipeline, but run with configuration:
> \`\`\`
> displayName: 'Visual Studio Test Platform Installer'
> inputs:
> packageFeedSelector: 'nugetOrg'
> versionSelector: 'specificVersion'
> testPlatformVersion: '17.9.0'
> \`\`\`
> \## Expected behavior
> Good representation of code coverage. External tools should be able to interpret coverage results.
> 
> \## Actual behavior
> Missing parts of coverage and external tools unable to interpret results. 
> 
> \## Environment
> Running agent on Windows: 10.0.17763
> Current agent version: '3.225.2'

---

<div class="post-metadata">

**Author:** ![norbert-groen](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/norbert-groen/32/58200_2.png) [@norbert-groen](https://community.sonarsource.com/u/norbert-groen)\
**Post date:** [May 29, 2024, 7:31am UTC](https://community.sonarsource.com/t/codecoverage-no-longer-reported-in-sonarqube/116079/3 "2024-05-29T07:31:21Z")

</div>

Today I filed an issue against the Visual Studio test platform.

[Code coverage seems to be broken in version 17.10.0 · Issue #5072 · microsoft/vstest (github.com)](https://github.com/microsoft/vstest/issues/5072)

It seems Codecoverage.exe from vstest is broken, but then again it is deprecated.  
So is there a planning to replace this tool?  
The tool itself states it should be replaced for: Microsoft.CodeCoverage.Console.

For now the problem is solved with using an “older” version of vstest.  
But in the future that will become a problem.

Norbert.

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [May 29, 2024, 7:37am UTC](https://community.sonarsource.com/t/codecoverage-no-longer-reported-in-sonarqube/116079/4 "2024-05-29T07:37:18Z")

</div>

Ah, hey @norbert-groen. I was really hoping you weren’t using SonarQube and these were independent issues. 😆

> [@Colin](#):
>
> There happens to be a Github issue (posted 12 minutes ago) claiming that that code coverage is broken with 17.10.0.

I’m going to flag this for attention by our .NET experts.

---

<div class="post-metadata">

**Author:** ![norbert-groen](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/norbert-groen/32/58200_2.png) [@norbert-groen](https://community.sonarsource.com/u/norbert-groen)\
**Post date:** [May 29, 2024, 7:40am UTC](https://community.sonarsource.com/t/codecoverage-no-longer-reported-in-sonarqube/116079/6 "2024-05-29T07:40:00Z")

</div>

Thanks!

---

<div class="post-metadata">

**Author:** ![milbrandt](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/milbrandt/32/3726_2.png) [@milbrandt](https://community.sonarsource.com/u/milbrandt)\
**Post date:** [May 29, 2024, 5:09pm UTC](https://community.sonarsource.com/t/codecoverage-no-longer-reported-in-sonarqube/116079/9 "2024-05-29T17:09:44Z")

</div>

I know of the [CodeCoverage.exe is deprecated](https://community.sonarsource.com/t/codecoverage-exe-is-deprecated/96312). We “fixed” it on the current repo by migration to coverlet and adjusting the pipeline.

---

<div class="post-metadata">

**Author:** ![MJHDiepman](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@MJHDiepman](https://community.sonarsource.com/u/MJHDiepman)\
**Post date:** [May 31, 2024, 7:15am UTC](https://community.sonarsource.com/t/codecoverage-no-longer-reported-in-sonarqube/116079/10 "2024-05-31T07:15:03Z")

</div>

we had the same symptom and in our case it was caused by the fact that the projects containing logic were classified as Test projects due to a reference to Moq and excluded from coverage:

INFO: Found 19 MSBuild C# projects: 3 MAIN projects. 16 TEST projects.

This can be solved in two ways:

1. Remove reference to Moq from projects containing logic
2. Explicitly tell Sonar what kind of project it is via the .csproj:  
`<SonarQubeTestProject>true/false</SonarQubeTestProject>`

---

<div class="post-metadata">

**Author:** ![Roland75](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/roland75/32/56834_2.png) [@Roland75](https://community.sonarsource.com/u/Roland75)\
**Post date:** [May 31, 2024, 10:13am UTC](https://community.sonarsource.com/t/codecoverage-no-longer-reported-in-sonarqube/116079/11 "2024-05-31T10:13:10Z")

</div>

Adding

`<SonarQubeTestProject>false</SonarQubeTestProject>`

to my csproj-files results in VS not loading the projects since this is an unrecognized tag.

---

<div class="post-metadata">

**Author:** ![milbrandt](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/milbrandt/32/3726_2.png) [@milbrandt](https://community.sonarsource.com/u/milbrandt)\
**Post date:** [May 31, 2024, 10:19am UTC](https://community.sonarsource.com/t/codecoverage-no-longer-reported-in-sonarqube/116079/12 "2024-05-31T10:19:59Z")

</div>

Where did you put it? In an Itemgroup or PropetyGroup? The following extract works for the property `SonarQubeTestProject`

```xml
    <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>net8.0</TargetFramework>
        <SonarQubeTestProject>true</SonarQubeTestProject>
    </PropertyGroup>

```

---

<div class="post-metadata">

**Author:** ![Roland75](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/roland75/32/56834_2.png) [@Roland75](https://community.sonarsource.com/u/Roland75)\
**Post date:** [May 31, 2024, 10:22am UTC](https://community.sonarsource.com/t/codecoverage-no-longer-reported-in-sonarqube/116079/13 "2024-05-31T10:22:49Z")

</div>

In an ItemGroup. Moved it to a PropertyGroup and now it works. Thanks.

---

<div class="post-metadata">

**Author:** ![anon35261157](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@anon35261157](https://community.sonarsource.com/u/anon35261157)\
**Post date:** [June 5, 2024, 12:07pm UTC](https://community.sonarsource.com/t/codecoverage-no-longer-reported-in-sonarqube/116079/15 "2024-06-05T12:07:26Z")

</div>

Any news here?

We got similar issue:

```auto
Executing file C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe
  Args: analyze ****
  Timeout (ms):60000
  Process id: 1488
CodeCoverage.exe is deprecated. Use dotnet-coverage global tool or Microsoft.CodeCoverage.Console instead. Some features of CodeCoverage.exe will be removed in next release of Visual Studio.

Process returned exit code -1
##[error]Failed to convert the binary code coverage reports to XML. No code coverage information will be uploaded to the server (SonarQube/SonarCloud).
Failed to convert the binary code coverage reports to XML. No code coverage information will be uploaded to the server (SonarQube/SonarCloud).
##[error]Check that the downloaded code coverage file ... is valid by opening it in Visual Studio. If it is not, check that the internet security settings on the build machine allow files to be downloaded from the Team Foundation Server machine.
Check that the downloaded code coverage file ***.cobertura.xml) is valid by opening it in Visual Studio. If it is not, check that the internet security settings on the build machine allow files to be downloaded from the Team Foundation Server machine.
Coverage report conversion completed successfully.
The TFS Processor has finished
Calling the SonarScanner CLI...

```

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [June 5, 2024, 1:14pm UTC](https://community.sonarsource.com/t/codecoverage-no-longer-reported-in-sonarqube/116079/16 "2024-06-05T13:14:57Z")

</div>

Hey all! 👋

So, yesterday Sonar released new versions of the [Azure DevOps Extension for SonarQube](https://docs.sonarsource.com/sonarqube/latest/analyzing-source-code/scanners/sonarqube-extension-for-azure-devops/) and [for SonarCloud](https://docs.sonarsource.com/sonarcloud/advanced-setup/ci-based-analysis/sonarcloud-extension-for-azure-devops/) which can finally use newer versions of the SonarScanner for MSBuild, where we have [migrated away from using CodeCoverage.exe.](https://github.com/SonarSource/sonar-scanner-msbuild/issues/1652)

Can you try upgrading to [_v6_ of the Azure DevOps tasks for SonarQube](https://docs.sonarsource.com/sonarqube/latest/devops-platform-integration/azure-devops-integration/#analyzing-projects-with-azure-pipelines) or [_v2_ for SonarCloud](https://docs.sonarsource.com/sonarcloud/advanced-setup/ci-based-analysis/sonarcloud-extension-for-azure-devops/)

---

<div class="post-metadata">

**Author:** ![almolo](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@almolo](https://community.sonarsource.com/u/almolo)\
**Post date:** [June 5, 2024, 1:21pm UTC](https://community.sonarsource.com/t/codecoverage-no-longer-reported-in-sonarqube/116079/18 "2024-06-05T13:21:39Z")

</div>

Hello, I’m having the same error. It’s coming from a very simple `SonarCloudAnalyze` task in Azure DevOps pipeline:

```auto
  - task: SonarCloudAnalyze@1
    displayName: Sonar Analysis

```

I’m assuming that behind the scenes this uses the latest available version (17.10.0)  
But since I’m not using `VisualStudioTestPlatformInstaller` task or anything like that, I don’t know how to rollback from 17.10.0 to 17.9.0… Any suggestions?

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [June 5, 2024, 1:23pm UTC](https://community.sonarsource.com/t/codecoverage-no-longer-reported-in-sonarqube/116079/19 "2024-06-05T13:23:50Z")

</div>

Hey @almolo

Can you try configuring v2 of the tasks (`SonarCloudAnalyze@2`) and see if it all comes together? See my post above.

---

<div class="post-metadata">

**Author:** ![almolo](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@almolo](https://community.sonarsource.com/u/almolo)\
**Post date:** [June 5, 2024, 1:52pm UTC](https://community.sonarsource.com/t/codecoverage-no-longer-reported-in-sonarqube/116079/20 "2024-06-05T13:52:48Z")

</div>

Hi Colin, I just tried v2 for SonarCloud. Output is different and there are less errors in it, but ultimately it still fails to upload code coverage to SonarCloud.

Output from SonarCloudAnalyze@1 was like this:

```auto
Executing file C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe
  Args: analyze /output:C:\a\3\s\TestResults\AzDevOps_aisar90cd000BJK_2024-06-05_13_02_40\In\aisar90cd000BJK\AzDevOps_aisar90cd000BJK_2024-06-05.13_02_41.cobertura.coveragexml C:\a\3\s\TestResults\AzDevOps_aisar90cd000BJK_2024-06-05_13_02_40\In\aisar90cd000BJK\AzDevOps_aisar90cd000BJK_2024-06-05.13_02_41.cobertura.xml 
  Working directory: C:\a\3\s\TestResults\AzDevOps_aisar90cd000BJK_2024-06-05_13_02_40\In\aisar90cd000BJK
  Timeout (ms):60000
  Process id: 5500
CodeCoverage.exe is deprecated. Use dotnet-coverage global tool or Microsoft.CodeCoverage.Console instead. Some features of CodeCoverage.exe will be removed in next release of Visual Studio.

Process returned exit code -1
Coverage report conversion completed successfully.
##[error]Failed to convert the binary code coverage reports to XML. No code coverage information will be uploaded to the server (SonarQube/SonarCloud).
Check that the downloaded code coverage file (C:\a\3\s\TestResults\AzDevOps_aisar90cd000BJK_2024-06-05_13_02_40\In\aisar90cd000BJK\AzDevOps_aisar90cd000BJK_2024-06-05.13_02_41.cobertura.xml) is valid by opening it in Visual Studio. If it is not, check that the internet security settings on the build machine allow files to be downloaded from the Team Foundation Server machine.
Failed to convert the binary code coverage reports to XML. No code coverage information will be uploaded to the server (SonarQube/SonarCloud).

```

Now output from SonarCloudAnalyze@2 is like this:

```auto
Converting coverage file 'C:\a\14\s\TestResults\AzDevOps_aisar90cd000BJ6_2024-06-05_13_35_33\In\aisar90cd000BJ6\AzDevOps_aisar90cd000BJ6_2024-06-05.13_35_33.cobertura.xml' to 'C:\a\14\s\TestResults\AzDevOps_aisar90cd000BJ6_2024-06-05_13_35_33\In\aisar90cd000BJ6\AzDevOps_aisar90cd000BJ6_2024-06-05.13_35_33.cobertura.coveragexml'.
Coverage report conversion completed successfully.
##[error]Failed to convert the binary code coverage reports to XML. No code coverage information will be uploaded to the server (SonarQube/SonarCloud).
Check that the downloaded code coverage file (C:\a\14\s\TestResults\AzDevOps_aisar90cd000BJ6_2024-06-05_13_35_33\In\aisar90cd000BJ6\AzDevOps_aisar90cd000BJ6_2024-06-05.13_35_33.cobertura.xml) is valid by opening it in Visual Studio. If it is not, check that the internet security settings on the build machine allow files to be downloaded from the Team Foundation Server machine.
Failed to convert the binary code coverage reports to XML. No code coverage information will be uploaded to the server (SonarQube/SonarCloud).

```

As you can see it no longer complains about CodeCoverage.exe being deprecated and there is no process exit code -1. There’s even a line saying “Coverage report conversion completed successfully.” But then it fails again.

---

<div class="post-metadata">

**Author:** ![Amit\_T](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/amit_t/32/48136_2.png) [@Amit\_T](https://community.sonarsource.com/u/Amit_T)\
**Post date:** [June 6, 2024, 5:28am UTC](https://community.sonarsource.com/t/codecoverage-no-longer-reported-in-sonarqube/116079/21 "2024-06-06T05:28:13Z")

</div>

it works for me…

---

<div class="post-metadata">

**Author:** ![almolo](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@almolo](https://community.sonarsource.com/u/almolo)\
**Post date:** [June 6, 2024, 4:12pm UTC](https://community.sonarsource.com/t/codecoverage-no-longer-reported-in-sonarqube/116079/23 "2024-06-06T16:12:46Z")

</div>

A small update on my issues with `SonarCloudAnalyze@2` - after fiddling around I realized v2 actually works, but only if my test coverage is in VS .coverage format. It does not work if coverage is in Cobertura format. Is cobertura not supported by SonarCloud v2?

---

<div class="post-metadata">

**Author:** ![dellch](https://avatars.discourse-cdn.com/v4/letter/d/ed655f/32.png) [@dellch](https://community.sonarsource.com/u/dellch)\
**Post date:** [June 6, 2024, 7:41pm UTC](https://community.sonarsource.com/t/codecoverage-no-longer-reported-in-sonarqube/116079/24 "2024-06-06T19:41:12Z")

</div>

Edit: apologies, we’re not using SonarCloud, we have a self-install - so I’m not sure if it is relevant.

I was able to fix this issue by using version `@6` of the tasks:

- `- task: SonarQubePrepare@6`
- `- task: SonarQubeAnalyze@6`
- `- task: SonarQubePublish@6`

Note that these versions are documented in [SonarQube’s docs here](https://docs.sonarsource.com/sonarqube/10.4/devops-platform-integration/azure-devops-integration/#steps-to-construct-your-azure-pipeline), but not in Microsoft’s Documentation ([link](https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/sonar-qube-analyze-v5?view=azure-pipelines))

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [June 10, 2024, 8:43am UTC](https://community.sonarsource.com/t/codecoverage-no-longer-reported-in-sonarqube/116079/25 "2024-06-10T08:43:24Z")

</div>

Thanks @almolo for raising a seperate thread about Cobertura.

> [@SonarCloudAnalyze@2 fails if code coverage is in Cobertura format](https://community.sonarsource.com/t/sonarcloudanalyze-2-fails-if-code-coverage-is-in-cobertura-format/116893):
>
> Environment: I have Azure DevOps pipeline and SonarCloud integration. It’s a .NET project. The problem - SonarCloudAnalyze@2 fails to process test coverage information when that information is in \*.cobertura.xml format. It only processes the coverage information when it’s in binary .coverage format. Question - is Cobertura format not supported by SonarCloudAnalyze@2, or is the problem somewhere else? First, pipeline code that works (coverage collected in .coverage format): - task: DotNetCore…

And thanks, @dellch, for pointing out the Azure DevOps docs. We don’t maintain these, but it looks like the folks who do update them on a monthly cadence.

---

<div class="post-metadata">

**Author:** ![norbert-groen](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/norbert-groen/32/58200_2.png) [@norbert-groen](https://community.sonarsource.com/u/norbert-groen)\
**Post date:** [June 11, 2024, 1:38pm UTC](https://community.sonarsource.com/t/codecoverage-no-longer-reported-in-sonarqube/116079/26 "2024-06-11T13:38:20Z")

</div>

Today we updated the Sonar Extension to version 6. It doesn’t use the codecoverage.exe anymore.  
So everything is fine now. We donot have to change our pipeline other than the versions of the tools.

**Thank you Sonarsource dotnet team!**

[Next page](https://community.sonarsource.com/t/codecoverage-no-longer-reported-in-sonarqube/116079.md?page=2)
