I’m trying to get the analysis to find the codecoverage.exe. It exists in several locations but setting VsTestToolsInstallerInstalledToolLocation is no help
SonarQube 9.6.1
Azure Build Agent : 2.209.0
Node.js 18.12.1
SonarQube ADO Tasks : 5.8.1 NO Visual Studio installation
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...
WARNING: CodeCoverage.exe was not found in the standard locations. Please provide the full path of the tool using the VsTestToolsInstallerInstalledToolLocation variable.
Attempting to locate the CodeCoverage.exe tool using setup configuration...
Attempting to locate the CodeCoverage.exe tool using registry...
WARNING: Failed to find the code coverage command line tool. Possible cause: Visual Studio is not installed, or the installed version does not support code coverage
Setting VsTestToolsInstallerInstalledToolLocation to D:\Agents\agent3\_work\_tool\VsTest\17.4.0\x64\tools\net462\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe
Setting VsTestToolsInstallerInstalledToolLocation to D:\Agents\agent3\_work\_tool\VsTest\17.4.0\x64\tools\net462\Team Tools\Dynamic Code Coverage Tools\amd64\CodeCoverage.exe
nuget install Microsoft.CodeCoverage in a directory and setting VsTestToolsInstallerInstalledToolLocation to that directory
Adding the Microsoft.CodeCoverage NuGet package to the xUnit test project of my solution
We have another build server where Visual Studio is installed and CodeCoverage is found successfully.
We don’t want to install it on this server as it’s unecessary.
Your setting for VsTestToolsInstallerInstalledToolLocation looks right. You have to include CodeCoverage.exe in the path as you did.
Therefore our assumption is, that the tool is not in the path specified by the environment variable. Can you make sure that the tool is actually installed at the location(s) specified?
I faced the same error. The environment variable is set by VisualStudioTestPlatformInstaller, but only the root path for all test-tools. The variable must be overwritten in the pipeline exactly for CodeCoverage.exe.
Like this
- task: PowerShell@2
displayName: Set path for CodeCoverage.exe
inputs:
targetType: 'inline'
script: |
Write-Host "VsTestToolsInstallerInstalledToolLocation value before: $($env:VsTestToolsInstallerInstalledToolLocation)"
Write-Host "Update VsTestToolsInstallerInstalledToolLocation environment variable."
$path=($env:VsTestToolsInstallerInstalledToolLocation) + "\tools\net462\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe"
Write-Host "##vso[task.setvariable variable=VsTestToolsInstallerInstalledToolLocation;]$($path)"
Write-Host "VsTestToolsInstallerInstalledToolLocation value after: $($env:VsTestToolsInstallerInstalledToolLocation)"
Thank you for sharing your solution to the problem. I’d like to better understand the root cause, so we can provide a fix and the workaround posted by you is no longer needed. Could you please share your VsTestPlatformToolInstallerV1 configuration, so we can reproduce the issue and see what we can do to find the coverage tool if the environment variable is set by the VsTestPlatformToolInstallerV1 task?
While I confirm that this works with .net SDK 6.0, it doesn’t with .net SDK 7.0
As far as I know, CodeCoverage.exe is not part of the .net SDK. Do you install the tool via the VisualStudioTestPlatformInstaller@1 task as described above? Can you please post the relevant parts of your pipeline (.Net SDK installation, Test platform installation)? I’m working on a fix right now and want to make sure it works in your configuration.