2016-09-07 99 views
0

我在关注this tutorial,它解释了如何将后构建事件附加到项目。Visual Studio在添加后构建事件后挂起

这是我.bat文件(试图与不D:rem D OUT):

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 S能,因为它没有被正确的合并无法正常运行。

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

+2

挂起这样的几乎都是靠不住的反恶意软件引起的。它从不喜欢看似无处可见的可执行文件。如果你使用Avast,特别容易发生永远悬挂的扫描,那么计划尽快摆脱它。 –

+0

@HansPassant感谢您的评论!我没有安装这样的东西,但会记住未来。请参阅我的答案,了解我是如何解决问题的 - 不确定链接教程为何不包含此部分 – Bassie

回答

1

我能够通过批处理文件调用ILMerge时指定targetFramework来解决此问题:

"..\..\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" 
相关问题