views:

2182

answers:

8

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 ILMerging assemblies together?

I'm looking for some advice in regards to using ILMerge to reduce deployment friction, if that is even possible.

James Pogran

+1  A: 

Maybe you should clarify what you mean by "reduce deployment friction." That sounds a lot like a marketing term that could mean lots and lots of different things.

DannySmurf
I would say it means: Have less files to copy.
Hmm, if it is just a matter of the time to select multiple files for xcopy deployment, then this is easy using NSIS installers that are built with NANT tasks. You can use a single NSIS file command to zip up all the files/subfolders in the bin/Release folder. As long as you have your project configured to produce only the files you want deployed then this is nice. Once you set this up the first time then you never really have to worry about how many assemblies there are.
AaronLS
+2  A: 

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.

Esteban Araya
+4  A: 

We use ILMerge on the Microsoft application blocks - instead of 12 seperate DLL files, we have a single file that we can upload to our client areas, plus the file system structure is alot neater.

After merging the files, I had to edit the visual studio project list, remove the 12 seperate assmeblies and add the single file as a reference, otherwise it would complain that it couldnt find the specific assembly. Im not too sure how this would work on post deployment though, could be worth giving it a try.

pzycoman
+1 for sharing your own experience.
Peter Mortensen
A: 

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.

muerte
+12  A: 

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.

Lamar
How did you do that release build integration?
Svish
@Svish -- http://www.hanselman.com/blog/MixingLanguagesInASingleAssemblyInVisualStudioSeamlesslyWithILMergeAndMSBuild.aspx
Sean Gough
Here's a potential workaround for ILMerge + XAML: http://richarddingwall.name/2009/05/14/wpf-how-to-combine-mutliple-assemblies-into-a-single-exe/
Scott Bilas
A: 

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.

longeasy
A: 

I recently had issue where I had ilmerged assembly in the assembly i had some classes these were being called via reflection in Umbraco opensource CMS.

The information to make the call via reflection was taken from db table that had assembly name and namespace of class that implemented and interface. The issue was that the reflection call would fail when dll was il merged however if dll was separate it all worked fine. I think issue may be similar to the one longeasy is having?

Ismail
A: 

It seems to me like the #1 ILMerge Best Practice is Don't Use ILMerge. Instead, use SmartAssembly. One reason for this is that the #2 ILMerge Best Practice is to always run PEVerify after you do an ILMerge, because ILMerge does not guarantee it will correctly merge assemblies into a valid executable.

Other ILMerge disadvantages:

  • when merging, it strips XML Comments (if I cared about this, I would use an obfuscation tool)
  • it doesn't correctly handle creating a corresponding .pdb file

Another tool worth paying attention to is Mono.Cecil and the Mono.Linker [2] tool.

[2]: http:// www.mono-project.com/Linker

"it doesn't correctly handle creating a corresponding .pdb file" - under what conditions is this true? I've watched ILMerge generate merged pdb's, and used them without issue.
Scott Bilas
When any of the assemblies you want to merge does not already have a .pdb. Also, SmartAssembly correctly handles WPF resources such as BAML.