We are using SonarCloud to analyze projects through Azure DevOps. We recently created a new build pipeline and SonarCloud project. The SonarCloud project was created manually. Other than the code coverage, the project/pipeline functions properly. The code coverage is saying 0%, but the same code/tests are recognized on our other SonarCloud projects. The analysis and testing tasks have been set up in Azure DevOps as the documentation describes.
Here is the beginning of the Run Analysis log:
Description : Run scanner and upload the results to the SonarCloud server.
Version : 1.19.0
Author : sonarsource
Help : Version: 1.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](https://sonarcloud.io/documentation/analysis/scan/sonarscanner-for-azure-devops/)
==============================================================================
D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.16.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe end
SonarScanner for MSBuild 5.0.4
Using the .NET Framework version of the Scanner for MSBuild
Here is where the code coverage tool runs. This log is consistent with our working SonarCloud pipelines/projects.
17:19:35.605 Writing processing summary to D:\a\1\.sonarqube\out\ProjectInfo.log
Calling the TFS Processor executable...
Executing file D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.16.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.TFSProcessor.exe
Args: ConvertCoverage D:\a\1\.sonarqube\conf\SonarQubeAnalysisConfig.xml D:\a\1\.sonarqube\out\sonar-project.properties
Working directory: D:\a\1
Timeout (ms):-1
Process id: 2280
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 (x86)\Microsoft Visual Studio\2019\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=2
D:\a\_temp\TestResults\0cec16ea-f00e-418a-9704-95a79c4577f4\VssAdministrator_WIN-2JAVS1DFC0O_2020-12-01.17_18_42.coverage
D:\a\_temp\TestResults\VssAdministrator_WIN-2JAVS1DFC0O_2020-12-01_17_19_05\In\WIN-2JAVS1DFC0O\VssAdministrator_WIN-2JAVS1DFC0O_2020-12-01.17_18_42.coverage
Unique coverage files: count=1
D:\a\_temp\TestResults\0cec16ea-f00e-418a-9704-95a79c4577f4\VssAdministrator_WIN-2JAVS1DFC0O_2020-12-01.17_18_42.coverage
Executing file C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe
Args: analyze /output:D:\a\_temp\TestResults\0cec16ea-f00e-418a-9704-95a79c4577f4\VssAdministrator_WIN-2JAVS1DFC0O_2020-12-01.17_18_42.coveragexml D:\a\_temp\TestResults\0cec16ea-f00e-418a-9704-95a79c4577f4\VssAdministrator_WIN-2JAVS1DFC0O_2020-12-01.17_18_42.coverage
Working directory: D:\a\_temp\TestResults\0cec16ea-f00e-418a-9704-95a79c4577f4
Timeout (ms):60000
Process id: 1868
Process returned exit code 0
Coverage report conversion completed successfully.
Process returned exit code 0
The TFS Processor has finished
Here is the end of the log. It appears as though SonarScanner is saying there are no coverage files.
17:21:16.733 INFO: Importing 23 Roslyn reports
17:21:16.872 INFO: Sensor C# [csharp] (done) | time=2180ms
17:21:16.873 INFO: Sensor C# Tests Coverage Report Import [csharp]
17:21:16.874 DEBUG: Analyzing coverage with wildcardPatternFileProvider with base dir 'D:\a\1\.' and file separator '\'.
17:21:16.877 DEBUG: Pattern matcher extracted prefix/absolute path 'D:\a' from the given pattern 'D:\a\_temp/**/*.coveragexml'.
17:21:16.879 DEBUG: Gathering files for wildcardPattern '_temp/**/*.coveragexml'.
17:21:24.580 DEBUG: Pattern matcher returns '1' files.
17:21:24.580 DEBUG: The current user dir is 'D:\a\1'.
17:21:24.581 INFO: Parsing the Visual Studio coverage XML report D:\a\_temp\TestResults\0cec16ea-f00e-418a-9704-95a79c4577f4\VssAdministrator_WIN-2JAVS1DFC0O_2020-12-01.17_18_42.coveragexml
...some DEBUG messages...
17:21:25.258 INFO: Adding this code coverage report to the cache for later reuse: D:\a\_temp\TestResults\0cec16ea-f00e-418a-9704-95a79c4577f4\VssAdministrator_WIN-2JAVS1DFC0O_2020-12-01.17_18_42.coveragexml
17:21:25.258 DEBUG: Analyzing coverage after aggregate found '0' coverage files.
17:21:25.258 DEBUG: The total number of file count statistics is '0'.
17:21:25.258 INFO: Sensor C# Tests Coverage Report Import [csharp] (done) | time=8385ms
17:21:25.258 INFO: Sensor Zero Coverage Sensor
17:21:25.328 INFO: Sensor Zero Coverage Sensor (done) | time=70ms
I have tried setting the following (individually):
sonar.cs.vstest.reportsPaths=$(Agent.TempDirectory)/*.trx
sonar.cs.vstest.reportsPaths=$(Agent.TempDirectory)/Sonar***.trx
sonar.cs.vscoveragexml.reportsPaths=$(Agent.TempDirectory)/**/*.coveragexml
but it has not helped.
I have also set verbose logging:
sonar.verbose=true