Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you create a standalone exe in Visual Studio? [duplicate]

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.

like image 223
dkellycollins Avatar asked Jun 19 '12 14:06

dkellycollins


2 Answers

.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
like image 62
gav Avatar answered Sep 30 '22 04:09

gav


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.

like image 37
MNGwinn Avatar answered Sep 30 '22 06:09

MNGwinn