<p>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?</p>

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

[{'answer_id': 9475, 'author': 'Esteban Araya', 'author_id': 781, 'author_profile': 'https://Stackoverflow.com/users/781', 'pm_score': 2, 'selected': False, 'text': '<p>We use ILMerge on quite a few projects. The <a href="http://www.codeplex.com/servicefactory" rel="nofollow noreferrer">Web Service Software Factory</a>, 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.</p>\n\n<p>It makes life somewhat easier, but it\'s not a big deal either.</p>\n'}, {'answer_id': 10967, 'author': 'Surgical Coder', 'author_id': 1276, 'author_profile': 'https://Stackoverflow.com/users/1276', 'pm_score': 3, 'selected': False, 'text': '<p>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. </p>\n\n<p>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.</p>\n'}, {'answer_id': 10972, 'author': 'markom', 'author_id': 1269, 'author_profile': 'https://Stackoverflow.com/users/1269', 'pm_score': 0, 'selected': False, 'text': '<p>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. </p>\n\n<p>We are considering doing the same with the MS Enterprise Library assemblies.</p>\n\n<p>The only real issue I see with it is versioning of individual assemblies from the package.</p>\n'}, {'answer_id': 34033, 'author': 'Lamar', 'author_id': 3566, 'author_profile': 'https://Stackoverflow.com/users/3566', 'pm_score': 7, 'selected': True, 'text': "<p>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.  </p>\n\n<p>You can't ILMerge any C++ assemblies that have native code.\nYou 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.</p>\n\n<p>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.</p>\n"}, {'answer_id': 1299402, 'author': 'Patrick', 'author_id': 30390, 'author_profile': 'https://Stackoverflow.com/users/30390', 'pm_score': 1, 'selected': False, 'text': "<p>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.</p>\n"}, {'answer_id': 3372483, 'author': 'Ismail', 'author_id': 406814, 'author_profile': 'https://Stackoverflow.com/users/406814', 'pm_score': 0, 'selected': False, 'text': '<p>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.  </p>\n\n<p>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?</p>\n'}, {'answer_id': 3561093, 'author': 'user429921', 'author_id': 429921, 'author_profile': 'https://Stackoverflow.com/users/429921', 'pm_score': -1, 'selected': False, 'text': '<p>It seems to me like the #1 ILMerge Best Practice is Don\'t Use ILMerge.  Instead, use <a href="http://www.red-gate.com/products/smartassembly/index.htm" rel="nofollow noreferrer">SmartAssembly</a>.  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.</p>\n\n<p>Other ILMerge disadvantages:</p>\n\n<ul>\n<li>when merging, it strips XML Comments (if I cared about this, I would use an obfuscation tool)</li>\n<li>it doesn\'t correctly handle creating a corresponding .pdb file</li>\n</ul>\n\n<p>Another tool worth paying attention to is Mono.Cecil and the Mono.Linker [2] tool.</p>\n\n<p>[2]: http:// www.mono-project.com/Linker</p>\n'}, {'answer_id': 9784933, 'author': 'Contango', 'author_id': 107409, 'author_profile': 'https://Stackoverflow.com/users/107409', 'pm_score': 5, 'selected': False, 'text': '<h2>Introduction</h2>\n\n<p>This post shows how to replace all <code>.exe + .dll files</code> with a single <code>combined .exe</code>. It also keeps the debugging <code>.pdb</code> file intact.</p>\n\n<h2>For Console Apps</h2>\n\n<p>Here is the basic <code>Post Build String</code> for Visual Studio 2010 SP1, using .NET 4.0. I am building a console .exe with all of the sub-.dll files included in it.</p>\n\n<pre><code>"$(SolutionDir)ILMerge\\ILMerge.exe" /out:"$(TargetDir)$(TargetName).all.exe" "$(TargetDir)$(TargetName).exe" "$(TargetDir)*.dll" /target:exe /targetplatform:v4,C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319 /wildcards\n</code></pre>\n\n<h2>Basic hints</h2>\n\n<ul>\n<li>The output is a file "<code>AssemblyName.all.exe</code>" which combines all sub-dlls into one .exe.</li>\n<li>Notice the <code>ILMerge\\</code> directory. You need to either copy the ILMerge utility into your solution directory (so you can distribute the source without having to worry about documenting the install of ILMerge), or change the this path to point to where ILMerge.exe resides.</li>\n</ul>\n\n<h2>Advanced hints</h2>\n\n<p>If you have problems with it not working, turn on <code>Output</code>, and select <code>Show output from: Build</code>. Check the exact command that Visual Studio actually generated, and check for errors.</p>\n\n<h1>Sample Build Script</h1>\n\n<p>This script replaces all <code>.exe + .dll files</code> with a single <code>combined .exe</code>. It also keeps the debugging .pdb file intact.</p>\n\n<p>To use, paste this into your <code>Post Build</code> step, under the <code>Build Events</code> tab in a C# project, and make sure you adjust the path in the first line to point to <code>ILMerge.exe</code>:</p>\n\n<pre><code>rem Create a single .exe that combines the root .exe and all subassemblies.\n"$(SolutionDir)ILMerge\\ILMerge.exe" /out:"$(TargetDir)$(TargetName).all.exe" "$(TargetDir)$(TargetName).exe" "$(TargetDir)*.dll" /target:exe /targetplatform:v4,C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319 /wildcards\nrem Remove all subassemblies.\ndel *.dll\nrem Remove all .pdb files (except the new, combined pdb we just created).\nren "$(TargetDir)$(TargetName).all.pdb" "$(TargetName).all.pdb.temp"\ndel *.pdb\nren "$(TargetDir)$(TargetName).all.pdb.temp" "$(TargetName).all.pdb"\nrem Delete the original, non-combined .exe.\ndel "$(TargetDir)$(TargetName).exe"\nrem Rename the combined .exe and .pdb to the original project name we started with.\nren "$(TargetDir)$(TargetName).all.pdb" "$(TargetName).pdb"\nren "$(TargetDir)$(TargetName).all.exe" "$(TargetName).exe"\nexit 0\n</code></pre>\n'}, {'answer_id': 13205241, 'author': 'Mightymuke', 'author_id': 1505426, 'author_profile': 'https://Stackoverflow.com/users/1505426', 'pm_score': 3, 'selected': False, 'text': '<p>I know this is an old question, but we not only use ILMerge to reduce the number of dependencies but also to internalise the "internal" dependencies (eg automapper, restsharp, etc) that are used by the utility. This means they are completely abstracted away, and the project using the merged utility doesn\'t need to know about them. This again reduces the required references in the project, and allows it to use / update its own version of the same external library if required.</p>\n'}, {'answer_id': 36601210, 'author': 'rexall', 'author_id': 5041136, 'author_profile': 'https://Stackoverflow.com/users/5041136', 'pm_score': 2, 'selected': False, 'text': '<p>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. </p>\n\n<p>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.</p>\n\n<p>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). </p>\n\n<p>The license is MIT as so you can modify/distribute as required.  </p>\n\n<p><a href="https://github.com/Fody/Costura/" rel="nofollow">https://github.com/Fody/Costura/</a></p>\n'}, {'answer_id': 36945225, 'author': 'Steve Pick', 'author_id': 2785150, 'author_profile': 'https://Stackoverflow.com/users/2785150', 'pm_score': 2, 'selected': False, 'text': '<p>I\'m just starting out using ILMerge as part of my CI build to combine a lot of finely grained WCF contracts into a single library. It works very well, however the new merged lib can\'t easily co-exist with its component libraries, or other libs that depend on those component libraries.</p>\n\n<p>If, in a new project, you reference both your ILMerged lib and also a legacy library that depends on one of the inputs you gave to ILMerge, you\'ll find that you can\'t pass any type from the ILMerged lib to any method in the legacy library without doing some sort of type mapping (e.g. automapper or manual mapping). This is because once everything\'s compiled, the types are effectively qualified with an assembly name.</p>\n\n<p>The names will also collide but you can fix that using <a href="https://blogs.msdn.microsoft.com/ansonh/2006/09/27/extern-alias-walkthrough/" rel="nofollow">extern alias</a>.</p>\n\n<p>My advice would be to avoid including in your merged assembly any publicly available lib that your merged assembly exposes (e.g. via a return type, method/constructor parameter, field, property, generic...) unless you know for sure that the user of your merged assembly does not and will never depend on the free-standing version of the same library.</p>\n'}, {'answer_id': 42510256, 'author': 'dlchambers', 'author_id': 210758, 'author_profile': 'https://Stackoverflow.com/users/210758', 'pm_score': 2, 'selected': False, 'text': "<p>Note that for windows GUI programs (eg WinForms) you'll want to use the /target:<strong>winexe</strong> switch. <br/>The /target:<strong>exe</strong> switch creates a merged <em>console</em> application.</p>\n"}]
['https://Stackoverflow.com/questions/9376', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1083/']