ILMerge is a utility that merges multiple .NET assemblies into a single assembly
MSBuild ILMerge task allows you to use the famous ILMerge utility in automated builds and/or Visual Studio 2013/2015 projects.
一、合併前
二、下載並安裝MSBuild.ILMerge.Task Nuget 包
三、安裝完成後項目中多了(或更新了)以下文件
四、重新編譯項目,dll與exe合併
五、更多應用請參見以下網址
https://archive.codeplex.com/?p=ilmergemsbuild
https://github.com/dotnet/ILMerge
https://www.microsoft.com/en-us/research/people/mbarnett/ilmerge/
六、補充,使用MSBuild.ILMerge.Task可能會遇到編譯成功但是exe無法運行的情況,另外的辦法是直接使用ILMerge,方法參照https://github.com/dotnet/ILMerge
七、其他異常情況:當程序使用Spring.net 或其他反射技術時打包後會出現程序無法運行的情況,原因是程序合併後程序集名稱會變化