Visual Studio在添加Post-Build-Event后挂起

时间:2016-09-07 11:18:37

标签: batch-file visual-studio-2015 post-build-event ilmerge

我正在关注this tutorial,它解释了如何将后期构建事件附加到项目中。

这是我的.bat文件(尝试使用和不使用D: rem d):

CMD
ECHO parameter=%1
CD %1
rem D:
COPY WpfFileDeleter.exe temp.exe
"..\..\ILMerge.exe" /out:"WpfFileDeleter.exe" "temp.exe" "Microsoft.WindowsAPICodePack.dll" "Microsoft.WindowsAPICodePack.ExtendedLinguisticServices.dll" "Microsoft.WindowsAPICodePack.Sensors.dll" "Microsoft.WindowsAPICodePack.Shell.dll" "Microsoft.WindowsAPICodePack.ShellExtensions.dll"
DEL temp.exe

我还根据教程添加了这个ILMerge.exe.config(我收到了Unresolved assembly reference not allowed错误):

<configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
        <requiredRuntime safemode="true" imageVersion="v4.0.30319" version="v4.0.30319"/>
    </startup>
</configuration>

但是当我在VS中构建我的项目时,它只会在Output

中挂起此消息
1>------ Rebuild All started: Project: WpfFileDeleter, Configuration: Debug Any CPU ------

我可以看到某些文件已复制到bin/debug,例如我指定的.dllstemp.exe,但任何WpfFileDeleter.exe都无法正常运行,因为它没有正确合并。

我的问题是如何调试此问题?是否有某种方法可以输出ILMerge的结果或构建过程,以便我可以看到它出错的地方?

1 个答案:

答案 0 :(得分:1)

我可以通过在批处理文件中调用targetFramework时指定ILMerge来解决此问题:

"..\..\ILMerge.exe" /out:"WpfFileDeleter.exe" /targetPlatform:"v4" "temp.exe" "Microsoft.WindowsAPICodePack.dll" "Microsoft.WindowsAPICodePack.ExtendedLinguisticServices.dll" "Microsoft.WindowsAPICodePack.Sensors.dll" "Microsoft.WindowsAPICodePack.Shell.dll" "Microsoft.WindowsAPICodePack.ShellExtensions.dll"