简体   繁体   English

配置ILMerge程序包

[英]Configuring ILMerge package

I have GUI c# project that has several additional packages in reference. 我有GUI c#项目,在参考中有几个其他软件包。 I would like to have executable without any additional dll's in build output. 我想要在生成输出中没有任何其他dll的可执行文件。 For this purpose I'm trying to use ILMerge package from nuget . 为此,我正在尝试使用nuget ILMerge软件包。 I have just installed package with command: 我刚刚使用以下命令安装了软件包:

Install-Package ilmerge -Version 3.0.18

But as result I got same executable that requires dll's. 但是结果是我得到了需要dll的可执行文件。 Should I do any configuration in my project in order to make ILMerge package build merged executable? 为了使ILMerge软件包生成合并可执行文件,我应该在项目中进行任何配置吗?

I can to propose to you another workaround, which works without any nuget packages, and just required some code: 我可以向您建议另一个解决方法,该方法无需任何nuget包即可工作,只需要一些代码即可:

  1. You should add all references of your project as Embeded Resources. 您应该将项目的所有引用添加为“嵌入资源”。
  2. After this in entrypoint of your app you should do next: 在应用程序的入口点执行此操作之后,您应该执行以下操作:

     AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve; private Assembly OnAssemblyResolve(object sender, ResolveEventArgs args) { var assemblyName = args.Name.Substring(0, args.Name.IndexOf(',')); var assembly = ...load binary from embeded resources as you wish based on assemblyName... return Assembly.Load(assembly); } 

profit: no additional packages. 利润:无额外包装。 Easy to use and debug. 易于使用和调试。

concern: hard to maintance if you have a lot of external packages. 注意:如果您有很多外部软件包,则很难维护。 Needs to add them manually to Embeded Resources. 需要将它们手动添加到“嵌入资源”中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM