gpt4 book ai didi

visual-studio-2010 - 合并 Visual Studio Code Coverage 失败并出现 ImageNotFoundException

转载 作者:行者123 更新时间:2023-12-02 07:46:41 27 4
gpt4 key购买 nike

我正在尝试将 visual studio 代码覆盖率文件 (data.coverage) 导出到 xml,如 this blog post from the code analysis team 中所述.我已将该帖子中的代码示例移至自定义 MSBuild 任务中。我的自定义任务引用了位于 Visual Studio 的 PrivateAssemblies 文件夹中的 Microsoft.VisualStudio.Coverage.Analysis.dll

马上,尝试加载代码覆盖率文件会抛出代码分析类型的异常 ImageNotFoundException,指出“图像文件 fully-qualified-file-path-to-dll could not be找到了。”

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

路径是完全限定的,它引用的 DLL 确实存在。我的测试设置将此文件列为仪器的程序集,并设置了“就地仪器”复选框。我可以在 Visual Studio 中查看代码覆盖率,因此我知道覆盖率是有效的。

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

<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>

任何人都可以建议我需要做什么才能使其正常工作吗?

最佳答案

5 小时后,这是风滚草。我找到了一些 additional detail here ,这帮助我走得更远。

为了使其正常工作,您需要在自定义任务旁边包含一些额外的文件,并为 pdb 和已检测的 dll 提供文件夹位置。

关于附加文件,您需要:

  1. 自定义构建任务必须引用 Microsoft.VisualStudio.Coverage.Analysis.dll
  2. 您的 bin 文件夹必须包含以下附加文件:

    • Microsoft.VisualStudio.Coverage.Symbols.dll
    • dbghelp.dll
  3. (如果没有安装visual studio,必须对msdia100.dll执行regsvr32.exe)

关于程序集和符号的路径,CreateFromFile 方法采用一组文件夹进行搜索。真正奇怪的是错误提示无法找到丢失的检测程序集,并且它指定了完整路径..

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

...但是如果您指定该路径,它就不起作用。

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

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

 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" });

我质疑“instrument in place”是否真的意味着在该文件夹中,或者仪器并复制到 MS 测试运行文件夹。

亲爱的 SO 伙计们,如果你正在读这篇文章,你会得到一 block cookies 。

关于visual-studio-2010 - 合并 Visual Studio Code Coverage 失败并出现 ImageNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6536738/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com