ILMerge Best Practices

前端 未结 12 2126
闹比i
闹比i 2020-11-28 20:19

Do you use ILMerge? Do you use ILMerge to merge multiple assemblies to ease deployment of dll\'s? Have you found problems with deployment/versioning in production after ILMe

相关标签:
12条回答
  • 2020-11-28 20:23

    We just started using ILMerge in our solutions that are redistributed and used in our other projects and so far so good. Everything seems to work okay. We even obfuscated the packaged assembly directly.

    We are considering doing the same with the MS Enterprise Library assemblies.

    The only real issue I see with it is versioning of individual assemblies from the package.

    0 讨论(0)
  • 2020-11-28 20:29

    We use ILMerge on quite a few projects. The Web Service Software Factory, for example produces something like 8 assemblies as its output. We merge all of those DLLs into a single DLL so that the service host will only have to reference one DLL.

    It makes life somewhat easier, but it's not a big deal either.

    0 讨论(0)
  • 2020-11-28 20:29

    We had the same problem with combining WPF dependencies .... ILMerge doesn't appear to deal with these. Costura.Fody worked perfectly for us however and took about 5 minutes to get going... a very good experience.

    Just install with Nuget (selecting the correct default project in the Package Manager Console). It introduces itself into the target project and the default settings worked immediately for us.

    It merges the all DLLs marked "Copy Local" = true and produces a merged .EXE (alongside the standard output), which is nicely compressed in size (much less than the total output size).

    The license is MIT as so you can modify/distribute as required.

    https://github.com/Fody/Costura/

    0 讨论(0)
  • 2020-11-28 20:32

    I use ILMerge for almost all of my different applications. I have it integrated right into the release build process so what I end up with is one exe per application with no extra dll's.

    You can't ILMerge any C++ assemblies that have native code. You also can't ILMerge any assemblies that contain XAML for WPF (at least I haven't had any success with that). It complains at runtime that the resources cannot be located.

    I did write a wrapper executable for ILMerge where I pass in the startup exe name for the project I want to merge, and an output exe name, and then it reflects the dependent assemblies and calls ILMerge with the appropriate command line parameters. It is much easier now when I add new assemblies to the project, I don't have to remember to update the build script.

    0 讨论(0)
  • 2020-11-28 20:33

    We ran into problems when merging DLLs that have resources in the same namespace. In the merging process one of the resource namespaces was renamed and thus the resources couldn't be located. Maybe we're just doing something wrong there, still investigating the issue.

    0 讨论(0)
  • 2020-11-28 20:34

    Note that for windows GUI programs (eg WinForms) you'll want to use the /target:winexe switch.
    The /target:exe switch creates a merged console application.

    0 讨论(0)
提交回复
热议问题