"CodeCoverage.exe is deprecated" warning in SonarCloudAnalyze@1 task

Hi,

We are using Azure pipeline task “SonarCloudAnalyze@1” on a Microsoft hosted agent but we still see this warning:
“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.”

The task prints these versions:
INFO: SonarScanner 4.8.1.3023
INFO: Java 17.0.9 Eclipse Adoptium (64-bit)
INFO: Windows Server 2022 10.0 amd64

Do we have do do something so we don’t see this warning?

Also see:

Best Regards,
Anders Havn

Hi Anders,

I don’t think that warning is coming from us.

 
Ann

Hi,

How can this warning not come from you? We are using your task in a yml file and this warning comes from the output of that task.

  • task: SonarCloudAnalyze@1

Best Regards,
Anders Havn

Hi Anders,

Screenshots of logs are really difficult to deal with. In general, we much prefer copy/pasted text.

From what I can tell, your pipeline is executing CodeCoverage.exe. That’s not coming from us. You might want to take a look at your YAML file…

 
Ann

I’m still not sure I understand. We are using your task in our pipeline and it is your task that outputs:

Executing file C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe

So it must be your sonar task there executes CodeCoverage.exe?

The following log from the task “- task: SonarCloudAnalyze@1” and ONLY from this task:

Calling the TFS Processor executable...
Attempting to locate the CodeCoverage.exe tool...
Attempting to locate the CodeCoverage.exe tool using setup configuration...
Code coverage command line tool: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\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: D:\a\1\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 D:\a\_temp
All matching files: count=4
	D:\a\_temp\2efc7fe8-376c-42e1-ad48-7a7a292756cc\VssAdministrator_fv-az610-807_2023-11-29.08_34_42.coverage
	D:\a\_temp\e4e058e6-bc6e-41c8-b828-94c788473cbc\VssAdministrator_fv-az610-807_2023-11-29.08_35_06.coverage
	D:\a\_temp\VssAdministrator_fv-az610-807_2023-11-29_08_34_09\In\fv-az610-807\VssAdministrator_fv-az610-807_2023-11-29.08_34_42.coverage
	D:\a\_temp\VssAdministrator_fv-az610-807_2023-11-29_08_34_46\In\fv-az610-807\VssAdministrator_fv-az610-807_2023-11-29.08_35_06.coverage
Unique coverage files: count=2
	D:\a\_temp\2efc7fe8-376c-42e1-ad48-7a7a292756cc\VssAdministrator_fv-az610-807_2023-11-29.08_34_42.coverage
	D:\a\_temp\e4e058e6-bc6e-41c8-b828-94c788473cbc\VssAdministrator_fv-az610-807_2023-11-29.08_35_06.coverage
Executing file C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe
  Args: analyze /output:D:\a\_temp\2efc7fe8-376c-42e1-ad48-7a7a292756cc\VssAdministrator_fv-az610-807_2023-11-29.08_34_42.coveragexml D:\a\_temp\2efc7fe8-376c-42e1-ad48-7a7a292756cc\VssAdministrator_fv-az610-807_2023-11-29.08_34_42.coverage 
  Working directory: D:\a\_temp\2efc7fe8-376c-42e1-ad48-7a7a292756cc
  Timeout (ms):60000
  Process id: 7032
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 0
Executing file C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe
  Args: analyze /output:D:\a\_temp\e4e058e6-bc6e-41c8-b828-94c788473cbc\VssAdministrator_fv-az610-807_2023-11-29.08_35_06.coveragexml D:\a\_temp\e4e058e6-bc6e-41c8-b828-94c788473cbc\VssAdministrator_fv-az610-807_2023-11-29.08_35_06.coverage 
  Working directory: D:\a\_temp\e4e058e6-bc6e-41c8-b828-94c788473cbc
  Timeout (ms):60000
  Process id: 2920
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 0
Coverage report conversion completed successfully.

Hi,

Can you share your pipeline code?

 
Ann

- task: SonarCloudPrepare@1
      inputs:
         SonarCloud: 'SonarCloud Paid Energinet Subscription'
         organization: 'energinet'
         scannerMode: 'MSBuild'
         projectKey: 'Energinet.DDP.Business_ForecastService'
         projectName: 'Energinet.DDP.Business_ForecastService'                   

    - task: DotNetCoreCLI@2
      displayName: 'Build $(buildConfiguration)'
      inputs:
        command: build
        projects: $(solution)
        arguments: '--no-restore --configuration $(buildConfiguration) /p:SourceRevisionId="$(Build.BuildNumber)"'

    - task: AzureCLI@2
      displayName: 'Run tests'
      inputs:
        azureSubscription: DEV_03_Resource_Manager
        scriptType: ps
        scriptLocation: scriptPath
        scriptPath: '$(scriptsPath)/runTests.ps1'
        arguments: '-testResultsDirectory $(Agent.TempDirectory) -dotnetTestParameters "--no-build --no-restore --filter Category!=IgnoreOnBuildAgent --configuration $(buildConfiguration) --collect `"Code coverage`" --settings $(Build.SourcesDirectory)\Source\.runsettings"'

    - task: PublishTestResults@2
      displayName: 'Publish Test Results'
      inputs:
        testRunner: VSTest
        # Exclude test results for SpecFlow tests as they will be published when running "publishSpecTestResult.ps1" below.
        testResultsFiles: |
          *.trx
          !*Specs*.trx
        searchFolder: $(Agent.TempDirectory)
        configuration: $(buildConfiguration)

    - task: SonarCloudAnalyze@1

    - task: SonarCloudPublish@1
      inputs:
        pollingTimeoutSec: '300'

Hi,

Thanks for sharing your pipeline. There’s quite a bit in there that we don’t have anything to do with:

What’s in ‘$(scriptsPath)/runTests.ps1’? Could that be where your call to CodeCoverage.exe is coming from?

 
Ann

The log I have pasted on this issue only comes from your task: “SonarCloudAnalyze@1”

So the following log statements definitely comes from the sonar task.

  • “Executing file C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe”
  • “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.”

Best Regards,
Anders Havn

Hi Anders,

Per the docs

SonarCloud itself does not calculate coverage. To include coverage results in your analysis, you must set up a third-party coverage tool and configure SonarCloud to import the results

We don’t run coverage tools.

 
Ann

Hi,

It seems you’re using an outdated task.

Please try to use the task SonarCloudAnalyze@5, this is the latest version.

Old versions used the CodeCoverage tool as can be seen on older docs:

Once trx files have been found, their .coverage counterpart are searched as well and the scanner tries to convert them to .coveragexml files that will be uploaded to SonarQube. CodeCoverage.exe tool is used for that, and the scanner also needs to find a path to that tool, following this search path(…)

This is not needed anymore.

1 Like

Could it be that the SonarQubeAnalyze@5 hasn’t been updated for this, since I still see this message in our build logs. (on version 5.18.3)

I can’t find any documention on task “SonarCloudAnalyze@5” and it does not work on the pipeline.

What about this issue:

Look like the same issue as me.

Actually, you are right, I’m sorry. The SonarCloudAnalyze@1 task is the correct one for SonarCloudAnalyze. The “v5” task is only for SonarQubeAnalyze.

It seems that the updates to make the process independent of CodeCoverage.exe haven’t been released yet and it looks like they’ll be included in the next release of SonarScanner for MSBuild.

Do you know when the next release of SonarScanner for MSBuild is?

Version 6.0 of the scanner was released today:

The Azure DevOps extensions will be released within the next few days.

Update: The Azure DevOps extensions will be released at the end of January.

2 Likes

Good morning everyone.

It seems that the new version of the DevOps 2022 extension is out, but the same error continues to occur :frowning:

Starting: Run Code Analysis
==============================================================================
Task         : Run Code Analysis
Description  : Run scanner and upload the results to the SonarQube server.
Version      : 5.19.0
Author       : sonarsource
Help         : Version: 5.19.0. This task is not needed for Maven and Gradle projects since the scanner should be run as part of the build.

[More Information](http://redirect.sonarsource.com/doc/install-configure-scanner-tfs-ts.html)
==============================================================================

...
Looking for TRX files in: C:\agent\_work\1\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:\agent\_work\_temp
All matching files: count=2
C:\agent\_work\_temp\0422a689-74bd-416c-8d15-a7a89adca717\deployearth_SONARQUBE01_2024-01-25.12_43_36.coverage
C:\agent\_work\_temp\deployearth_SONARQUBE01_2024-01-25_12_41_23\In\SONARQUBE01\deployearth_SONARQUBE01_2024-01-25.12_43_36.coverage
Unique coverage files: count=1
C:\agent\_work\_temp\0422a689-74bd-416c-8d15-a7a89adca717\deployearth_SONARQUBE01_2024-01-25.12_43_36.coverage
Executing file C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe
  Args: analyze /output:C:\agent\_work\_temp\0422a689-74bd-416c-8d15-a7a89adca717\deployearth_SONARQUBE01_2024-01-25.12_43_36.coveragexml C:\agent\_work\_temp\0422a689-74bd-416c- 8d15- a7a89adca717\deployearth_SONARQUBE01_2024-01-25.12_43_36.coverage
  Working directory: C:\agent\_work\_temp\0422a689-74bd-416c-8d15-a7a89adca717
  Timeout (ms):60000
  Process id: 11456
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.

Hi @DarioFlores

You don’t seem to be using the new version.

 
HTH,
Ann

Hello Ann.

Thank you for your prompt response, in DevOps 2022 the sonar extension is in version 5.19, which may still need to be updated.

I only have this update:

Extension details: Detect bugs, vulnerabilities and code smells across project branches and pull requests.
Publisher: SonarSource
Installed version: 5.19.0 (Latest)
Last updated: 24 ene 2024 at 19:36 GMT-3

Cordial greetings
Darío Flores