合并Visual Studio代码覆盖率失败,出现ImageNotFoundException [英] Merging Visual Studio Code Coverage fails with ImageNotFoundException

查看:67
本文介绍了合并Visual Studio代码覆盖率失败,出现ImageNotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Visual Studio代码覆盖率文件(data.coverage)导出到xml中,如

I'm trying to export visual studio code coverage files (data.coverage) into xml as described in this blog post from the code analysis team. I've moved the code example in that post into a custom MSBuild task. My custom task references the Microsoft.VisualStudio.Coverage.Analysis.dll located in the PrivateAssemblies folder of Visual Studio.

立即采取行动,尝试加载代码覆盖文件会引发代码分析类型为ImageNotFoundException的异常,指出图像文件完全合格的文件路径到dll 找到."

Right off the bat, trying to load the code coverage file throws an code analysis typed exception ImageNotFoundException, stating that the "Image file fully-qualified-file-path-to-dll could not be found."

 // the following line throws an exception
 CoverageInfo current = 
     CoverageInfo.CreateFromFile( "c:\path\testresults\x\y\z\data.coverage");

该路径是完全限定的,并且它所引用的DLL确实存在.我的测试设置已将此文件列为要检测的装配件,并设置了仪器就位"复选框.我可以在Visual Studio中查看代码覆盖率,因此我知道覆盖率是有效的.

The path is fully qualified and the DLL it refers to does exist. My testsettings has this file listed as the assembly to instrument and the "Instrument in place" checkbox is set. I can view code coverage within Visual Studio, so I know coverage is working.

我正在从Visual Studio命令行运行MSBuild脚本.看起来像这样:

I'm running my MSBuild script from the Visual Studio command line. It looks like this:

<Project ToolsVersion="4.0" DefaultTargets="Default;"
      xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

   <UsingTask TaskName="CustomTasks.MergeCoverageTask" 
      AssemblyFile="CustomTasks.dll" 
      />

   <Target Name="Default">

      <ItemGroup>
         <CoverageFiles Include="**\data.coverage" />
      </ItemGroup>

      <MergeCoverageTask
           CoverageFiles="@(CoverageFiles)"
           OutputFile="output.xml"
           />
   </Target>
 </Project>

有人能建议我需要做些什么才能使其正常工作吗?

Can anyone suggest what I need to do to get this working correctly?

推荐答案

5小时后,这是风滚草.我发现了一些

5 hours later and this is a tumbleweed. I found some additional detail here, which helped get me further down the path.

要使其正常工作,您需要在自定义任务旁边添加一些其他文件,并为pdb和检测的dll提供文件夹位置.

In order for this to work, you need to include a few additional files alongside the custom task and supply folder locations for the pdb's and instrumented dll's.

关于其他文件,您需要以下内容:

Regarding additional files, you need the following:

  1. 自定义生成任务必须引用Microsoft.VisualStudio.Coverage.Analysis.dll
  2. 您的bin文件夹必须包含以下其他文件:

  1. The custom build task must reference Microsoft.VisualStudio.Coverage.Analysis.dll
  2. Your bin folder must contain the following additional files:

  • Microsoft.VisualStudio.Coverage.Symbols.dll
  • dbghelp.dll

(如果未安装Visual Studio,则必须在msdia100.dll上执行regsvr32.exe)

(If you don't have visual studio installed, you must perform regsvr32.exe on msdia100.dll)

关于程序集和符号的路径, CreateFromFile 方法采用一组文件夹进行搜索.似乎真正奇怪的是,该错误抱怨无法找到丢失的检测装配,并指定了完整路径.

Regarding paths to assemblies and symbols, the CreateFromFile method takes a collection of folders to search. What seems really strange is that error complains about not being able to locate missing instrumented assemblies, and it specifies the full path..

找不到图像文件c:\ project \ output \ Assembly.dll.

Image file c:\project\output\Assembly.dll could not be found.

...但是,如果您指定该路径,则无法使用.

...but if you specify that path, it doesn't work.

 CoverageInfo current = 
 CoverageInfo.CreateFromFile( "c:\project\testresults\x\In\data.coverage", 
              new string[] { "c:\project\output" },
              new string[] { "c:\project\output" });

但是,将路径更改为TestResults输出的文件夹可以正常工作:

However, changing the path to be the folder of the TestResults output works fine:

 CoverageInfo current = 
 CoverageInfo.CreateFromFile( "c:\project\testresults\x\In\data.coverage", 
              new string[] { "c:\project\testresults\x\Out" },
              new string[] { "c:\project\testresults\x\Out" });

我质疑仪器就位"是否真的意味着该文件夹中的 或仪器并将其复制到MS Test运行文件夹中.

I question whether "instrument in place" really means in that folder, or instrument and copy to the MS Test run folder.

亲爱的亲爱的人们,如果您正在阅读这篇文章,就会得到一个cookie.

Well dear SO folk, if you're reading this, you get a cookie.

这篇关于合并Visual Studio代码覆盖率失败,出现ImageNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆