Thursday, September 7, 2017

Merge DLL into EXE on WPF via LibZ | 使用LibZ在WPF上將DLL合併至EXE內

In winform, you can use ILMerge merge DLLs into EXE, but it can't work on WPF, so we need find another way to do it. Lot of people recommend this post "Combining multiple assemblies into a single EXE for a WPF application", but it didn't work on me, luckily I found another way to do it.
在winform上,你可以用ILMerge合併DLLs到EXE裡,但是在WPF上沒辦法辦到,所以我們需要找另外的方法來達成。很多人推薦這篇" Combining multiple assemblies into a single EXE for a WPF application "的方式,但是在我的情況不適用,還好我找到另外的方式。


Using LibZ, we can use commend line doing merge like using ILMerge, you can even use LibZ as library to control it in code for advanced use. For me, Libz can merge DLLs into EXE on WPF, it saved my day.
使用LibZ,我們可以跟ILMerge一樣用指令列來做合併,在進階的狀況,甚至可以在程式內呼叫LibZ library來使用他。對我來說,LibZ可以在WPF上將DLLs合併至EXE內,這省了我很多時間。


LibZ github nuget


To use LibZ is easy, the fast way for me is use NuGet Package Manager Console (in Visual Studio -> Tools -> NuGet Package Manager -> Package Manager Console)
使用LibZ很簡單,最快的方式就是使用NuGet Package Manager Console (在Visual Studio中-> Tools -> NuGet Package Manager -> Package Manager Console)


Open NuGet Package Manager Console, type in following commend to install
開啟NuGet Package Manager Console,輸入下列指令安裝
PM>Install-Package LibZ.Tool -Version 1.2.0
libz1


After LibZ.Tool package installed, goto the dictionary that having you want to merge's file, using following commend to merge DLLs into EXE.
LibZ.Tool安裝完後,到有你要合併的檔案之目錄,使用下列指令來將DLLs合併至EXE.

PM>libz inject-dll --assembly .\YOUREXE.exe --include .\YOURDLL.dll
libz2


Then it's done.
然後就完成啦。


You can read LibZ document to get more help.
你可以閱讀LibZ的文件來取得更多幫助。

No comments:

Post a Comment