Is there a way to compile C# files into one single file that is ready to give to the user?
+9
A:
One way is to use ILMerge. This will merge multiple assemblies into a single one (think combining all DLLs and a main exe into a single exe).
dpp
2009-02-15 03:48:27
Do you know of any good tutorials on how to use this tool?
Lucas McCoy
2009-02-15 03:57:24
A short but useful article from CodeProject: http://www.codeproject.com/KB/dotnet/mergingassemblies.aspx
dpp
2009-02-15 04:14:40
+2
A:
Yes :) But you must put all your sources into a single assembly and compile it to an EXE. Also note that the target system must also have the required .NET infrastructure installed.
Note that security policies on the target system may prevent the user from directly running your app.
Lastly, unless you "NGEN" your code, it will be jitted the first time it runs. This will incur some startup time costs. THese can be considerable in some instances.
Foredecker
2009-02-15 03:50:56
The jitting that occurs should be no different than if the program were a set of assemblies - jitting occurs on a method-by-method basis when each method is first called. Presumably, methods will be called in the same sequence whether the program is packaged in a single .exe or several assemblies.
Michael Burr
2009-02-15 04:01:54
@Michael - unless there was an edit, the only reference to JIT relates to NGEN; in which case, no: it *won't* be jitted on a method-by-method basis...
Marc Gravell
2009-02-15 08:13:10
@Marc - I was thinking that the NGEN comment implied that combining the assemblies into a single .exe would increase the startup time over having multiple assemblies. In other words, I was trying to say that whether you want or need NGEN is likely independent of whether your assemblies are merged.
Michael Burr
2009-02-15 20:23:59