21

I have a .net application with about 10 assemblies. It would be nice to have them all together as a single assembly. How do I do it?

I guess something like a jar file for Java applications.

BartoszKP
  • 34,786
  • 15
  • 102
  • 130
Russell
  • 17,481
  • 23
  • 81
  • 125
  • See: http://stackoverflow.com/questions/1878807/visual-studio-2008-creating-single-dll-from-solution-with-many-projects – CAD bloke Sep 23 '10 at 23:22
  • 2
    Thanks @CAD Bloke, that answer provides quite a lot of detail. It was actually asked a week after this one, and foresight doesn't come with the .Net framework yet. :) – Russell Sep 24 '10 at 03:49
  • No probs - I (presume - this was a while ago) added the link for visitors later in time. – CAD bloke Apr 17 '13 at 10:05
  • 1
    Possible duplicate of [How to merge multiple assemblies into one?](http://stackoverflow.com/questions/8077570/how-to-merge-multiple-assemblies-into-one) – BartoszKP Dec 23 '15 at 16:44

3 Answers3

22

Try ILMerge.

NuGet package here

blins
  • 2,515
  • 21
  • 32
Andy West
  • 12,302
  • 4
  • 34
  • 52
12

Using ILMerge is probably the simplest solution. However, ILMerge has the drawback that it changes the identity of referenced assemblies. As a consequence, you might run into issues with security or serialization.

An excellent blog post by Simone Busoli discusses the following options to merge assemblies into a single executable:

  1. ILMerge
  2. Embedding assemblies as a resource and subscribing to the AssemblyResolve event.
  3. Using Costura, an open source tool which takes care of embedding referenced assemblies as described in step 2.
Bernhard Barker
  • 54,589
  • 14
  • 104
  • 138
Dirk Vollmar
  • 172,527
  • 53
  • 255
  • 316
9

ILMerge is the tool you're looking for:

ILMerge

The documentation for ILMerge can be found here:

http://research.microsoft.com/en-us/people/mbarnett/ILMerge.aspx

Kev
  • 118,037
  • 53
  • 300
  • 385