How to pass LCOV file created to sonar for .NET code coverage running on ubuntu-latest env via github actions?

For dotnet project, trying to get code coverage created and passed on to sonar in Linux env.

  1. code coverage : coverlet.msbuild

dotnet test --no-restore ${{ inputs.test_project_file }} --verbosity quiet -p:CollectCoverage=true -p:CoverletOutputFormat=lcov -p:CoverletOutput="${GITHUB_WORKSPACE}/TestResults/"

  1. sonar property used for passing the code coverage file. (uses: sonarsource/sonarqube-scan-action@v1.0.0)
  • SonarQube Version 9.2.4

How can I confirm that the file is used by sonar for code coverage ? (As it shows 0.0% code coverage in dashboard and no verbose logs stating the given report path is used.)


You appear to be missing an ‘s’; it should be plural: sonar.javascript.lcov.reportPaths.

Can you try that?


Thanks Ann, missed this typo. This worked.


  1. Code coverage for C# files is not considered in this approach I assume. How can I ensure this ?

Just throwing random thoughts,

dotnet test --no-restore ${{ inputs.test_project_file }} --verbosity quiet -p:CollectCoverage=true -p:CoverletOutputFormat=lcov -p:CoverletOutput="${GITHUB_WORKSPACE}/TestResults/"

  • This creates file but only covers the js files and code coverage for c# files to be done separately. As this is run using github actions in an ubuntu-latest environment, does it have any issues ?

Am I right in this above understanding ? Using the following for sonar integration, Will this work for .NET ? if not, is there any example file for github actions for sonar on .NET I can refer to ?


  1. dotnet test lcov
    • uses: sonarsource/sonarqube-scan-action@v1.0.0 github action for sonar.


I’ll start by saying I’m not a .NET expert.

The SonarScanner for .NET docs indicate that the tests should be run after the begin step. So:


And from there they should be picked up automatically. Can you verify the order you’re running things in?

Also, you seem to be specifying the test report output location? Maybe let that use the default…?


P.S. This thread is already tagged to draw the attention of people who are .NET experts, so if my fumblings don’t help, someone should be along soon.