I am working on the integration of SonarCloud with Az DevOps, currently the analysis result is generated, but CodeCoverage.exe tool can not convert my test coverage report file to XML.
Config:
.Net Framework
Vs Build
Vs Test Installed by Tools Installer
I got the following error:
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).
##[error]Check that the downloaded code coverage file (C:\path\filename.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.
Hi, is this some kind of recent change either on part of MS or on part of SQ?
I’m faced with the same error and it seems there’s no way to move forward with this. Or, at least, I’m not sure how I’m supposed to collect code-coverage results when creating a basic .NET-centric build/test DevOps pipeline…
I’m having the same problem as well since last Thursday 5/23
Starting: Run Code Analysis
==============================================================================
Task : Run Code Analysis
Description : Run scanner and upload the results to the SonarCloud server.
Version : 1.45.0
Author : sonarsource
Help : Version: 1.45.0. This task is not needed for Maven and Gradle projects since the scanner should be run as part of the build.
[More Information](https://docs.sonarcloud.io/advanced-setup/ci-based-analysis/sonarcloud-extension-for-azure-devops/)
==============================================================================
C:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.41.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe end
SonarScanner for MSBuild 5.15
Using the .NET Framework version of the Scanner for MSBuild
Post-processing started.
Calling the TFS Processor executable...
Attempting to locate the CodeCoverage.exe tool...
VsTestToolsInstallerInstalledToolLocation environment variable detected, seeking for CodeCoverage.exe location...
VsTestToolsInstallerInstalledToolLocation environment variable doesn't contain full path to CodeCoverage.exe tool, seeking in standard place set by VSTestPlatformToolInstaller: C:\a\_tool\VsTest\17.10.0\x64 and tools\net451\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe
VsTestToolsInstallerInstalledToolLocation environment variable doesn't contain full path to CodeCoverage.exe tool, seeking in standard place set by VSTestPlatformToolInstaller: C:\a\_tool\VsTest\17.10.0\x64 and tools\net462\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe
CodeCoverage.exe found at C:\a\_tool\VsTest\17.10.0\x64\tools\net462\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe.
Code coverage command line tool: C:\a\_tool\VsTest\17.10.0\x64\tools\net462\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe
Fetching code coverage report information from TFS...
Attempting to locate a test results (.trx) file...
Looking for TRX files in: C:\a\14\TestResults
No test results files found
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 C:\a\_temp
All matching files: count=4
C:\a\_temp\a09e3501-8d70-4baa-8f06-c8fa2529a339\AzDevOps_buildvse0015U6_2024-05-28.02_37_21.coverage
C:\a\_temp\a4e51c3a-97a6-44ba-bc4b-8ef3fc10e707\AzDevOps_buildvse0015U6_2024-05-28.02_37_08.coverage
C:\a\_temp\AzDevOps_buildvse0015U6_2024-05-28_02_37_08\In\buildvse0015U6\AzDevOps_buildvse0015U6_2024-05-28.02_37_08.coverage
C:\a\_temp\AzDevOps_buildvse0015U6_2024-05-28_02_37_19\In\buildvse0015U6\AzDevOps_buildvse0015U6_2024-05-28.02_37_21.coverage
Unique coverage files: count=2
C:\a\_temp\a09e3501-8d70-4baa-8f06-c8fa2529a339\AzDevOps_buildvse0015U6_2024-05-28.02_37_21.coverage
C:\a\_temp\a4e51c3a-97a6-44ba-bc4b-8ef3fc10e707\AzDevOps_buildvse0015U6_2024-05-28.02_37_08.coverage
Executing file C:\a\_tool\VsTest\17.10.0\x64\tools\net462\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe
Args: analyze /output:C:\a\_temp\a09e3501-8d70-4baa-8f06-c8fa2529a339\AzDevOps_buildvse0015U6_2024-05-28.02_37_21.coveragexml C:\a\_temp\a09e3501-8d70-4baa-8f06-c8fa2529a339\AzDevOps_buildvse0015U6_2024-05-28.02_37_21.coverage
Working directory: C:\a\_temp\a09e3501-8d70-4baa-8f06-c8fa2529a339
Timeout (ms):60000
Process id: 5888
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).**
Check that the downloaded code coverage file (C:\a\_temp\a09e3501-8d70-4baa-8f06-c8fa2529a339\AzDevOps_buildvse0015U6_2024-05-28.02_37_21.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.
**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\_temp\a09e3501-8d70-4baa-8f06-c8fa2529a339\AzDevOps_buildvse0015U6_2024-05-28.02_37_21.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...
INFO: Scanner configuration file: C:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.41.0\classic-sonar-scanner-msbuild\sonar-scanner-4.8.1.3023\bin\..\conf\sonar-scanner.properties
INFO: Project root configuration file: C:\a\14\.sonarqube\out\sonar-project.properties
INFO: SonarScanner 4.8.1.3023
We too experience this issue. Has worked for a few months until yesterday evening. Our build server has multiple versions of VS installed, and yesterday it seems one of them was upgraded from Multiple 17.9.34728.123 to 17.10.34916.146. The version for the coverage collection tool seems to be the same. I suspect the version of VS that our build server uses expects the results from the dotnet-coverage-task rather than the deprecated CodeCoverage.exe that is run through dotnet test --collect “Code Coverage”, but I haven’t been able to get it to work again.
I was able to surpass this issue too by updating to the newest version (SonarCloudPrepare@2, SonarCloudAnalyze@2 and SonarCloudPublish@2) of the sonar tasks. It works on classic pipelines both on onprem an dcloud solutions in Azure DevOps. However, we are using yaml pipelines as well (trying to upgrade from classic to yaml), and although the yaml looks alike, the code coverage fails for the yaml pipelines after pulling the latest code from the main branch, so it seems a bit unstable.
To give further info:
Until a few weeks ago, we had around 10 pipelines for different system. These pipelines use the classic pipeline from Azure DevOps. But we have a goal to replace these classic pipelines with yaml pipelines, meaning the pipelines should produce the same results. However, once I fixed the code coverage issue for the classic pipelines, I haven’t fully been able to do so with the yaml pipelines (yet). This is what I’ve observed so far:
Pipeline name
Description
Result
Source code status
classic
Original classic pipeline
Code coverage is displayed both in Azure Devops (Extensions-tab) and SonarCloud
Latest source code from main branch
original
An exact export from the classic pipeline
Code coverage is displayed both in Azure Devops (Extensions-tab) and SonarCloud
Not pulled latest source code from main branch
replica
An exact export from the classic pipeline, identical to original pipeline
Code coverage lacks from both in Azure Devops (Extensions-tab) and SonarCloud
Latest source code from main branch
To be clear: The tasks in the pipeline doesn’t fail, but code coverage isn’t displayed as I expect. I expect the measure code coverage to be here and in SonarCloud, but it isn’t for the replica pipeline. I’m very confused, because the replica and original pipeline have identical setup, differing only in source code, while the classic and replica pipeline have identical source code and should have identical setup too. But yet the replica pipeline fails, and I cannot figure out why.
To give some context, CodeCoverage.exe has been deprecated for a while now by Microsoft.
I am guessing that the new release of MSBuild 17.10 has made some changes in the format that are not compatible with CodeCoverage.exe.
With the release of the new Azure DevOps tasks for SonarQube and SonarCloud (respectively v6 and v2), you can now specify which version of the SonarScanner for .NET you want to use.
By default, the tasks will use the latest version of SonarScanner for .NET which is 6.2.0
Since version 6.0.0, SonarScanner for .NET does not rely on CodeCoverage.exe for automatic code coverage detection (check the release note for more info) which explains why upgrading to the latest version of the tasks fixes the issue.
TL;DR Updating to the latest Azure DevOps tasks fixes the code coverage import issue, as they no longer rely on CodeCoverage.exe.
For me its exactly the other way around with tasks version @5 it works, but switching to @6 breaks with “Failed to convert the binary code coverage reports to XML.”
I’ll investigate further.
Update
The offensive file is a valid cobertura coverage file like