"WARN: Unable to get next XML event while parsing file" .NET coverage problem

Hello there

After digging the complete posts, I couldn’t find any answer to this below import coverage failure.

2021-10-15T00:02:43.8585442Z 13:02:43.854 INFO: Sensor C# Tests Coverage Report Import [csharp]
2021-10-15T00:02:43.8586070Z 13:02:43.854 DEBUG: Analyzing coverage with wildcardPatternFileProvider with base dir ‘E:\agent1_work\4.’ and file separator ‘’.
2021-10-15T00:02:43.8586831Z 13:02:43.854 DEBUG: Pattern matcher extracted prefix/absolute path ‘E:\agent1_work_temp’ from the given pattern ‘E:\agent1_work_temp***.coverage’.
2021-10-15T00:02:43.8590221Z 13:02:43.854 DEBUG: Gathering files for wildcardPattern ‘***.coverage’.
2021-10-15T00:02:43.8734558Z 13:02:43.864 DEBUG: Pattern matcher returns ‘2’ files.
2021-10-15T00:02:43.8734962Z 13:02:43.864 DEBUG: The current user dir is ‘E:\agent1_work\4’.
2021-10-15T00:02:43.8735559Z 13:02:43.864 INFO: Parsing the Visual Studio coverage XML report E:\agent1_work_temp\TestResults\36733ed4-51c2-40d0-b52d-14356e1d10ef\result.coverage
2021-10-15T00:02:43.9589861Z 13:02:43.944 WARN: Unable to get next XML event while parsing file ‘E:\agent1_work_temp\TestResults\36733ed4-51c2-40d0-b52d-14356e1d10ef\resutl.coverage’
2021-10-15T00:02:43.9592554Z 13:02:43.949 WARN: Could not import coverage report ‘E:\agent1_work_temp\TestResults\36733ed4-51c2-40d0-b52d-14356e1d10ef\result.coverage’ because ‘Error while parsing the XML file: E:\agent1_work_temp\TestResults\36733ed4-51c2-40d0-b52d-14356e1d10ef\result.coverage’. Troubleshooting guide: [Coverage] Troubleshooting guide for .NET code coverage import
2021-10-15T00:02:43.9594307Z 13:02:43.949 DEBUG: The current user dir is ‘E:\agent1_work\4’.
2021-10-15T00:02:43.9595207Z 13:02:43.949 INFO: Parsing the Visual Studio coverage XML report E:\agent1_work_temp\TestResults\build-machine$_build-machine_2021-10-15_12_52_54\In\build-machine\result.coverage
2021-10-15T00:02:43.9603150Z 13:02:43.949 WARN: Unable to get next XML event while parsing file ‘E:\agent1_work_temp\TestResults\build-machine$_build-machine_2021-10-15_12_52_54\In\build-machine\result.coverage’
2021-10-15T00:02:43.9605031Z 13:02:43.949 WARN: Could not import coverage report ‘E:\agent1_work_temp\TestResults\build-machine$_build-machine_2021-10-15_12_52_54\In\build-machine\result.coverage’ because ‘Error while parsing the XML file: E:\agent1_work_temp\TestResults\build-machine$_build-machine_2021-10-15_12_52_54\In\build-machine\result.coverage’. Troubleshooting guide: [Coverage] Troubleshooting guide for .NET code coverage import

Thanks in advance.

Cheers!

Hi @mano ,

Welcome to SonarSource Community! :sonarsource:

Your warning says the problem: WARN: Unable to get next XML event while parsing file ‘E:\agent1_work_temp\TestResults\36733ed4-51c2-40d0-b52d-14356e1d10ef\resutl.coverage’

Your .coverage file will get converted to a .coveragexml, which should look something like this:

<?xml version="1.0" encoding="UTF-8" ?>
<results>
  <modules>
    <module name="someconsoleapplicationtest.dll" path="someconsoleapplicationtest.dll" id="91AE251F1EB91F4DA6A7BB0A38B3ABDF01000000" block_coverage="100.00" line_coverage="100.00" blocks_covered="6" blocks_not_covered="0" lines_covered="9" lines_partially_covered="0" lines_not_covered="0">
      <functions>
...

Please give us the following version information:

  • what is the version of SonarQube that you are using?
  • what is the version of the Scanner for .NET (MSBuild) that you are using?
  • what version of MSBuild are you using?

And we’ll need the logs:

  • please give us the verbose output of the scanner commands (please run SonarScanner.MSBuild.exe begin /k:“MyProject” /d:sonar.verbose=true as the begin step, and please attach the output of the BEGIN and END steps)
  • please give the output of running MSBuild in verbose mode (/v:d)

Also, please tell us:

  • what are the commands you are running to do the analysis?
  • are you running all commands from the same folder?

In addition, please see the following guides (I added some of the same links for your reference):

Joe