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

Visual Studio Hangs After Adding Post-Build-Event

我正在关注 this tutorial,它解释了如何将 post-build 事件附加到项目。

这是我的 .bat 文件(尝试使用和不使用 D: remd 输出):

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 或构建过程的结果,以便我可以看到哪里出了问题?

我能够通过在批处理文件中调用 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"