Skip to content

Commit 735cd16

Browse files
Fix SonarCloud coverage always reporting 0% (#15)
* Initial plan * Fix SonarCloud coverage: use dotnet-coverage collect with vscoveragexml format Co-authored-by: 304NotModified <5808377+304NotModified@users.noreply.github.com> * Use --no-incremental on build step as required by SonarScanner docs Co-authored-by: 304NotModified <5808377+304NotModified@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: 304NotModified <5808377+304NotModified@users.noreply.github.com>
1 parent 822498c commit 735cd16

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

.github/workflows/sonarcloud.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- name: Install SonarScanner for .NET
2828
run: |
2929
dotnet tool install --global dotnet-sonarscanner
30-
dotnet tool install --global dotnet-reportgenerator-globaltool
30+
dotnet tool install --global dotnet-coverage
3131
3232
- name: Restore dependencies
3333
run: dotnet restore SLNX-validator.slnx
@@ -41,16 +41,13 @@ jobs:
4141
/o:"304notmodified" \
4242
/d:sonar.token="${SONAR_TOKEN}" \
4343
/d:sonar.host.url="https://sonarcloud.io" \
44-
/d:sonar.coverageReportPaths="coverage/SonarQube.xml"
44+
/d:sonar.cs.vscoveragexml.reportsPaths="coverage.xml"
4545
4646
- name: Build
47-
run: dotnet build SLNX-validator.slnx --no-restore -c Release
47+
run: dotnet build SLNX-validator.slnx --no-incremental -c Release
4848

4949
- name: Test with coverage
50-
run: dotnet test --solution SLNX-validator.slnx --no-build -c Release --verbosity normal -- --coverage --coverage-output-format cobertura
51-
52-
- name: Convert coverage to SonarQube format
53-
run: reportgenerator -reports:"**/TestResults/**/*.cobertura.xml" -targetdir:coverage -reporttypes:SonarQube
50+
run: dotnet-coverage collect "dotnet test --solution SLNX-validator.slnx --no-build -c Release --verbosity normal" -f xml -o coverage.xml
5451

5552
- name: End SonarCloud analysis
5653
env:

0 commit comments

Comments
 (0)