# VS 2015 cannot open .coveragexml generated by CodeCoverage.exe

### Question

• You can see same post at; VS 2015 cannot open .coveragexml generated by CodeCoverage.exe

Since I could not get any answer from there, I am posting here as well.

I am following Code Coverage Results Import (C#, VB.NET) documentation for SonarQube.

For my project, I am able to generate test coverage binary file as "SonarQubeTests.csproj.coverage"

Visual Studio can open this file with no problem. I can see all the details.

Then when I try to generate ".coveragexml" file with following command;

"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe" "analyze /output:C:\SonarQubeTests.csproj.coveragexml C:\SonarQubeTests.csproj.coverage"


It does generate ".coveragexml" file, but when I try to open Visual Studio it gives me following error:

I can pen this file with text editor and content seems all fine. But neither Visual Studio 2015 nor sonarqube does not read this file.

What I am missing here?

P.S I have also runner settings for Ms Test runner as below. Not sure if this will effect something;

    <?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<!-- Configurations that affect the Test Framework -->
<RunConfiguration>
<MaxCpuCount>1</MaxCpuCount>
<!-- Path relative to solution directory -->
<ResultsDirectory>C:\</ResultsDirectory>

<!-- [x86] | x64
- You can also change it from menu Test, Test Settings, Default Processor Architecture -->
<TargetPlatform>x86</TargetPlatform>

<!-- Framework35 | [Framework40] | Framework45 -->
<TargetFrameworkVersion>Framework45</TargetFrameworkVersion>

<!-- Path to Test Adapters -->
</RunConfiguration>

<!-- Configurations for data collectors -->
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Configuration>
<CodeCoverage>
<ModulePaths>
<Exclude>
<ModulePath>.*CPPUnitTestFramework.*</ModulePath>
</Exclude>
</ModulePaths>

<!-- We recommend you do not change the following values: -->
<UseVerifiableInstrumentation>True</UseVerifiableInstrumentation>
<AllowLowIntegrityProcesses>True</AllowLowIntegrityProcesses>
<CollectFromChildProcesses>True</CollectFromChildProcesses>
<CollectAspDotNet>False</CollectAspDotNet>

</CodeCoverage>
</Configuration>
</DataCollector>

</DataCollectors>
</DataCollectionRunSettings>

<!-- Parameters used by tests at runtime -->
<TestRunParameters>
<Parameter name="webAppUrl" value="http://localhost" />
</TestRunParameters>

<MSTest>
<MapInconclusiveToFailed>True</MapInconclusiveToFailed>
<CaptureTraceOutput>false</CaptureTraceOutput>
<DeleteDeploymentDirectoryAfterTestRunIsComplete>False</DeleteDeploymentDirectoryAfterTestRunIsComplete>
<DeploymentEnabled>False</DeploymentEnabled>
<AssemblyResolution>
<Directory Path="D:\myfolder\bin\" includeSubDirectories="false"/>
</AssemblyResolution>
</MSTest>

</RunSettings>

 

• Edited by Wednesday, March 22, 2017 10:43 PM
Wednesday, March 22, 2017 10:40 PM

### All replies

• Hi reyou,

>>I can pen this file with text editor and content seems all fine. But neither Visual Studio 2015 nor sonarqube does not read this file

Please create a new empty unit test and export the code coverage, compare the code coverage format to see which place has difference.

If possible, please share me your code coverage file, I will try to open it in my side to see whether has the same issue.

And please try to use the following command to generate code coverage, and refer to the following MSDN document:

vstest.console.exe MyTestAssembly.dll /EnableCodeCoverage

https://msdn.microsoft.com/en-us/library/dd537628.aspx

Sincerely,

Oscar

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

Thursday, March 23, 2017 8:19 AM
• Hello @Oscar,

2. https://github.com/reyou/OCoverSampleCons
3. Then build OCoverSampleCons.sln
4. Navigate to powershell script
5. https://github.com/reyou/OCoverSampleCons/blob/master/powershell/vstest.ps1
6. Change TODO marked parameters ($outputFolder,$projectRoot)
7. Run powershell script
8. check output folder. There should be .coverage and .coveragexml files
9. Try to open both files with VS 2015
10. .coverage file will open, but not .coveragexml file.

Please let me know if you need further information.

• Edited by Monday, March 27, 2017 7:50 PM links
Monday, March 27, 2017 7:49 PM
• Hello Oscar, I would like to confirm you were able to download project and run locally.

Please let me know if you need further information.

Thanks!

Tuesday, March 28, 2017 3:06 PM
• Hi reyou,

I got the following error messages if I run the script.

Whether I use the same steps as yours?

Best Regards,

Jack

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

Wednesday, March 29, 2017 10:53 AM
• Hello Jack,

Seems like your \$projectRoot parameter is wrong. It should point to "C:\temp\OCoverSampleCons-master" in your case in your powershell file. Also please make sure to build OCoverSampeCons.sln before your run the powershell script.

Thanks.

• Edited by Wednesday, March 29, 2017 1:11 PM
Wednesday, March 29, 2017 12:39 PM
• Hi reyou,

I got the same issue as yours.

The VS IDE couldn't open this file generated by the CodeCoverage.exe.

I get some information from the report site:

The only supported way to get this codecoverage is via the IDE or the vstest.console commandline with the /EnableCodeCoverage option, my understanding is that we couldn't use that command line （“CodeCoverage.exe”）directly, actually if you export the  .coveragexml files from the VS IDE's coverage result, it has the different contents as the  .coveragexml file generated by the CodeCoverage.exe directly..

https://connect.microsoft.com/VisualStudio/feedback/details/858813/different-block-coverage-reported-by-visual-studio-and-codecoverage-exe-analyze

Best Regards,

Jack

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

Thursday, March 30, 2017 9:31 AM
• Hi Jack,

Is there any suggested resolution for this? Maybe new version of Visual Studio fix it? (2017)

Thursday, March 30, 2017 1:10 PM
• Hi reyou,

You are welcome.

I also test it in VS2017 RTM, it still doesn't support it.

Like my previous suggestion, if you really want to get the .coveragexml file, you could run it in VS IDE(In Test Explorer window), and then export the file if you want to get/save it.

Best Regards,

Jack

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

Friday, March 31, 2017 9:01 AM