vsinstr.exe无法读取从各个Visual Studio版本生成的.dll文件

时间:2018-06-22 17:03:36

标签: visual-studio-2015 visual-studio-2017

我正在使用PowerShell脚本来获取项目中DLL的代码覆盖率。

它总是在每个DLL上出错。

我将其范围缩小到VSInstr.exe。

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Performance Tools>vsinstr.exe -coverage C:\GitRepos\ProjectName\src\ProjectName\bin\ProjectName.dll
Microsoft (R) VSInstr Post-Link Instrumentation 14.0.25420 x86
Copyright (C) Microsoft Corp. All rights reserved.

Error VSP1033: The file 'C:\GitRepos\ProjectName\src\ProjectName\bin\ProjectName.dll' does not contain a recognized executable image.

如果我在2017年清理并重建并在2017 Performance Tools文件夹中尝试相同的exe,则会得到完全相同的错误。

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Team Tools\Performance Tools>vsinstr.exe -coverage C:\GitRepos\ProjectName\src\ProjectName\bin\ProjectName.dll
Microsoft (R) VSInstr Post-Link Instrumentation 15.0.26720 x86
Copyright (C) Microsoft Corp. All rights reserved.

Error VSP1033: The file 'C:\GitRepos\ProjectName\src\ProjectName\bin\ProjectName.dll' does not contain a recognized executable image.

这些.dll文件是否在相应的IDE中无法正确构建?我需要为VSInstr设置一些在VS中的选项或首选项,以便能够正确读取DLL吗?

我不是办公室里唯一一个针对从Visual Studio创建的.dll文件运行VSInstr.exe时出现此错误的人。

我知道他们可以被其他办公室的同事阅读,并且能够从git下拉我的分支,进行构建,并通过PowerShell脚本和VSInstr.exe命令行成功运行.dll文件,但是我每次我都需要为该项目和其他项目运行此脚本时,我不能找他。

1 个答案:

答案 0 :(得分:1)

发现我们在64位PC上使用任何CPU进行构建,但是内部有x64版本的vsinstr.exe

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Performance Tools\x64
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Team Tools\Performance Tools\x64

对于在构建过程中创建的这些.dll文件,应该引用它。