合并Visual Studio代码覆盖率失败,出现ImageNotFoundException

编程入门 行业动态 更新时间:2024-10-28 09:18:00
本文介绍了合并Visual Studio代码覆盖率失败,出现ImageNotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试将Visual Studio代码覆盖率文件(data.coverage)导出到xml中,如此博客来自代码分析团队,.我已将该文章中的代码示例移至自定义MSBuild任务中.我的自定义任务引用了位于Visual Studio的PrivateAssemblies文件夹中的 Microsoft.VisualStudio.Coverage.Analysis.dll .

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="schemas.microsoft/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:

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

  • The custom build task must reference Microsoft.VisualStudio.Coverage.Analysis.dll
  • 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

    本文发布于:2023-11-14 10:44:13,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1587006.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:覆盖率   代码   Visual   Studio   ImageNotFoundException

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!