5

Possible Duplicate:
Embedding DLLs in a compiled executable

I want to compile my C# application to a single exe file. The problem is that my project depends on many other projects resulting in many dlls in the Release folder when I compile it. Is there any way to just make an exe with these dlls included?

Note: It does not need to be independent from the .NET framework. I assume that anyone using this exe will have that installed.

Community
  • 1
  • 1
dkellycollins
  • 497
  • 6
  • 17

3 Answers3

9

.NET ships with a tool called ILMerge where multiple assemblies can be packaged together into a single file. You would use it like:

ilmerge /target:winexe /out:myoneexecutable.exe Foo.exe Bar1.dll Bar2.dll
Ufuk Hacıoğulları
  • 37,978
  • 12
  • 114
  • 156
gav
  • 131
  • 1
  • It hadnt bothered me to worry about separate files, but I stumbled upon this, and now of course theres no chance someone will accidentally delete 1 part of the file, or mix versions etc.. Thank you! – BugFinder Jun 19 '12 at 15:07
2

ILMerge is one option, but it can't merge WPF assemblies. You can embed assemblies as resources and dynamically load them. See this Richter article.

MNGwinn
  • 2,394
  • 17
  • 18
0

I believe the closest you will get to being able to compile to a single executable is using Visual Studio's Setup Project functionality / Wizards to generate a standard MSI package which you can then use to distribute your application.

There may well be 3rd party tools available that allow you to condense everything down into one file, however. But I don't believe this will gain you anything over the standard MSI approach - indeed, it's just an extra manual step in the build process which you don't strictly need.

Benemon
  • 73
  • 7