Dotnet sonar scanner end is failing after dotnet dotcover

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    Sonarqube: 8.9
    Sonar Scanner: 5.3

  • what are you trying to achieve:

In github actions i am trying to run the below commands with my project and token.

dotnet sonarscanner begin /k:“sonar-project-key”
dotnet build
dotnet dotcover test --dcReportType=HTML
dotnet sonarscanner end /d:sonar.login=“sonar-token”

Error in the pipeline:

[JetBrains dotCover] Analyzed application exited with code '1'

[JetBrains dotCover] Coverage session finished [12/15/2022 04:08:09]

[JetBrains dotCover] Coverage results post-processing started [12/15/2022 04:08:09]

[JetBrains dotCover] Merging snapshots [12/15/2022 04:08:09]

[JetBrains dotCover] Snapshots merging finished [12/15/2022 04:08:09]

[JetBrains dotCover] Report generation started [12/15/2022 04:08:09]

[JetBrains dotCover] Report generation finished [12/15/2022 04:08:10]

[JetBrains dotCover] Coverage results post-processing finished [12/15/2022 04:08:10]

Error: Process completed with exit code 253.

I am trying to publish the code coverage in the sonar project.

  • what have you tried so far to achieve this
    All the commands are running as bash in the yaml
- name: Sonarqube
        shell: bash
        run: |
          project_name=`basename ${{ github.workspace }}`
          export PATH=$PATH:/home/user/.dotnet/tools
          cd ${{ github.workspace }}
          dotnet nuget add source --username USERNAME --password ${{ secrets.NUGET_AUTH_TOKEN }} --store-password-in-clear-text --name github ""
          dotnet tool install --global JetBrains.dotCover.GlobalTool
          dotnet sonarscanner begin /k:"$project_name" /"https://localhost:9000" /d:sonar.login="${{ secrets.SONARQUBE_TOKEN }}" /d:sonar.cs.dotcover.reportsPaths=dotCover.Output.html 
          dotnet build
          dotnet dotcover test --dcReportType=HTML 
          dotnet sonarscanner end  /d:sonar.login="${{ secrets.SONARQUBE_TOKEN }}"

If i run without /d:sonar.cs.dotcover.reportsPaths=dotCover.Output.html  and dotnet dotcover test --dcReportType=HTML 

it is publishing the report but without code coverage.

Krishna Mohan

Hey there.

SonarQube only reads coverage reports, it’s not involved in producing them. So if this command is failing with a non-zero exit code…

I would suggest making sure dotnet dotcover test --dcReportType=HTML succeeds without involving SonarQube analysis (the dotnet sonarscanner steps), and then add it back in.

Thank you for the response.

I found the issue and resolved it. When I execute the dotnet sonarscanner as a new step then I realised issue is with the dotnet dotcover command.

In my case, the below commands worked perfectly.

dotnet sonarscanner begin /k:"<project name>" /"https://localhost:9000" /d:sonar.login="${{ secrets.SONARQUBE_TOKEN }}" /d:sonar.cs.dotcover.reportsPaths=report.html

dotnet build

dotnet dotcover test --no-restore --filter Category=UnitTest -r "unittest" --logger "trx" --dcOutput="report.html" --dcReportType=HTML --dcFilters="+:xxx.*;-:*.Tests.*;"

dotnet sonarscanner end  /d:sonar.login="${{ secrets.SONARQUBE_TOKEN }}"