我正在关注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
,例如我指定的.dlls
和temp.exe
,但任何WpfFileDeleter.exe
都无法正常运行,因为它没有正确合并。
我的问题是如何调试此问题?是否有某种方法可以输出ILMerge的结果或构建过程,以便我可以看到它出错的地方?
答案 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"