2016-09-07 142 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" 
相關問題