Hi community,
I’m integrating SonarQube with a .NET 8 project and trying to import code coverage using an OpenCover XML report generated via coverlet.
I run the following command to generate the report:
dotnet test /p:CollectCoverage=true /p:CoverletOutput=coverage/ /p:CoverletOutputFormat=opencover
This successfully creates coverage.opencover.xml
in the coverage/
folder.
Then I run the SonarScanner like this:
dotnet sonarscanner begin /k:“MyProjectKey” ^
/d:sonar.host.url=“http://localhost:9000” ^
/d:sonar.login=“MY_TOKEN” ^
/d:sonar.cs.opencover.reportsPaths=“coverage/coverage.opencover.xml”
dotnet build
dotnet sonarscanner end /d:sonar.login=“MY_TOKEN”
The analysis completes successfully, but when I open the SonarQube dashboard, I don’t see any coverage data — it shows 0% coverage.
Things I’ve checked:
- The
coverage.opencover.xml
file exists and is not empty. - The report path is relative to the solution root.
- I’m using the latest SonarScanner for .NET and SonarQube 10.x (please confirm if specific version matters).
Am I missing something? Is there a better way to feed coverlet coverage
data to SonarQube?
Thanks in advance!