Skip to content

Fix SonarCloud coverage always reporting 0%#15

Merged
304NotModified merged 4 commits into
mainfrom
copilot/fix-sonarcloud-coverage
Mar 6, 2026
Merged

Fix SonarCloud coverage always reporting 0%#15
304NotModified merged 4 commits into
mainfrom
copilot/fix-sonarcloud-coverage

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 6, 2026

  • Investigate root cause: Microsoft.Testing.Extensions.CodeCoverage generates empty cobertura XML files (<packages /> with no data), causing 0% coverage in SonarCloud
  • Fix sonarcloud.yml workflow:
    • Replaced dotnet-reportgenerator-globaltool with dotnet-coverage tool installation
    • Use dotnet-coverage collect to properly capture coverage data as VS Coverage XML
    • Use sonar.cs.vscoveragexml.reportsPaths instead of sonar.coverageReportPaths
    • Removed the reportgenerator conversion step (no longer needed)
    • Changed build flag from --no-restore to --no-incremental as required by the SonarSource docs — this ensures all files are rebuilt so SonarScanner can instrument them

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…ml format

Co-authored-by: 304NotModified <5808377+304NotModified@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix test coverage to ensure sonarcloud compliance Fix SonarCloud coverage always reporting 0% Mar 6, 2026
@304NotModified
Copy link
Copy Markdown
Owner

@copilot still won't work. Read the docs

Co-authored-by: 304NotModified <5808377+304NotModified@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 6, 2026

@copilot still won't work. Read the docs

Fixed in 33267d7. The docs specify dotnet build --no-incremental — this is required so SonarScanner instruments all source files during the build. Using --no-restore was skipping that instrumentation step.

@304NotModified 304NotModified marked this pull request as ready for review March 6, 2026 21:38
@304NotModified 304NotModified merged commit 735cd16 into main Mar 6, 2026
4 checks passed
@304NotModified 304NotModified deleted the copilot/fix-sonarcloud-coverage branch March 6, 2026 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants