Generated coverage.opencover.xml file cannot be parsed

Versions used

  • SonarQube Enterprise Edition Version 8.9.1 (build 44547)
  • SonarScanner 4.6.2.2472

Sonar Scanner end command log

INFO: Sensor C# Tests Coverage Report Import [csharp]
INFO: Parsing the OpenCover report C:\source\<solutin-folder>\src\.\.\coverage.opencover.xml
WARN: Unable to get next XML event while parsing file '.\.\coverage.opencover.xml'
WARN: Could not import coverage report '.\.\coverage.opencover.xml' because 'Error while parsing the XML file: C:\source\<solution-folder>\src\.\.\coverage.opencover.xml'. Troubleshooting guide: https://community.sonarsource.com/t/37151
INFO: Sensor C# Tests Coverage Report Import [csharp] (done) | time=4ms

Steps to reproduce

  • generate coverage report for entire solution
  • merge reports into one file (i.e. coverage.opencover.xml)
  • expect failure on parsing when publishing the report on scanner end command

Potential workaround

  • keep coverage files separated for multiple projects in the same solution

The workaround might be the official way, nonetheless as we are using make files, if there is a way to pass a regex like **/*coverage.opencover.xml to reportPaths switch that would be generic enough for me

Hello @alan.costa.iress

Welcome to the community !

Could you please share the commands you are running to do the analysis and to generate the coverage reports and to merge them?

Is it possible to share the coverage file w/ us? It seems it doesn’t have the expected file format.

Yes, we do this in our own pipeline (https://github.com/SonarSource/sonar-dotnet/blob/master/azure-pipelines.yml#L230)

sonar.cs.opencover.reportsPaths=“$(Build.SourcesDirectory)/coverage/**.xml”

1 Like

Ah, if you do that I’m happy with it as well. I’ll close this issue

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.