Must-share information (formatted with Markdown):
-
which versions are you using
SonarScanner for MSBuild 5.15 (Azure DevOps plugin) -
how is SonarQube deployed
SonarQube server 9.9.4.87374 -
what are you trying to achieve
Make SonarQube identify and upload my code coverage -
what have you tried so far to achieve this
I’ve read available documentation, applied suggestions from other similar post but so far, no success.
Description
My project is a .NET 8 project written in C#.
I’m using a local hosted build agent.
My test project as the coverlet.msbuild
nugget added.
My pipeline runs my unit tests like this:
- task: DotNetCoreCLI@2
displayName: "Run unit tests"
inputs:
command: test
projects: '**/MyUnitTests.csproj'
publishTestResults: true
arguments: '--runtime win-x64 /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura'
I publish my code coverage this way:
- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage results'
condition: succeeded()
inputs:
codeCoverageTool: 'Cobertura'
summaryFileLocation: '**/*coverage.cobertura.xml'
With this my unit tests are executed and the code coverage collected and published in my Azure DevOps build page. However the build server is on-premise and runs an agent builder.
I can see in my Azure build log mentions to code coverage in my task ‘SonarQubeAnalyze’ but nothing is found or updated to my SonarQube server. See these messages:
C:\agent\_work\_tasks\SonarQubePrepare_XXXXXXX-b62f-4a2a-a403-89b77a063157\5.19.1\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...
Attempting to locate the CodeCoverage.exe tool using setup configuration...
Code coverage command line tool: E:\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: C:\agent\_work\4\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
No coverage files found in the agent temp directory.
Coverage report conversion completed successfully.
Also found this:
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: 'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=3ms
And at the end:
INFO: Sensor C# File Caching Sensor [csharp]
INFO: Sensor C# File Caching Sensor [csharp] (done) | time=192ms
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=190ms
INFO: CPD Executor 45 files had no CPD blocks
Looking in my test task log I see:
C:\agent\_work\_tool\dotnet\dotnet.exe test C:\agent\_work\2\s\myproject\MyProject.UnitTests\MyProject.UnitTests.csproj --logger trx --results-directory C:\agent\_work\_temp --runtime win-x64 /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura
Determining projects to restore...
// >>> List of projects restored here... <<<
MyProject.DataStore -> C:\agent\_work\2\s\MyProject.DataStore\MyProject.DataStore\bin\Debug\net8.0\win-x64\MyProject.DataStore.dll
Sonar: (MyProject.DataStore.csproj) Project processed successfully
MyProject.DataStore.UnitTests -> C:\agent\_work\2\s\MyProject.DataStore\Myproject.DataStore.UnitTests\bin\Debug\net8.0\win-x64\MyProject.DataStore.UnitTests.dll
Sonar: (MyProject.DataStore.UnitTests.csproj) Project processed successfully
[coverlet] _mapping file name: 'CoverletSourceRootsMapping_MyProject.DataStore.UnitTests'
Test run for C:\agent\_work\2\s\MyProject.DataStore\MyProject.DataStore.UnitTests\bin\Debug\net8.0\win-x64\MyProject.DataStore.UnitTests.dll (.NETCoreApp,Version=v8.0)
Microsoft (R) Test Execution Command Line Tool Version 17.9.0 (x64)
Copyright (c) Microsoft Corporation. All rights reserved.
What am I missing?
Best regards