C# – Static Linking of libraries created on C# .NET

cnetvisual-studio-2008

I'm using VS2008 C#.NET.

I created 3 different classes of libraries in 3 projects. I wrote an application which uses these libraries (dlls).

What is happening is each project is compiling into a class library. So, I've 3 dlls and 1 exe.

Instead I want to have these in two ways:

  1. Only class library assembly (dll) which contains 3 of them and 1 exe.
  2. just one EXE (everything inside it) :: static linking.

How could I do that? I cannot find any options for static linking in VS2008 also please mention commandline options too.

Best Answer

ILMerge is what you're after.

I'm not sure I'd really call this "static linking" - it's just merging several assemblies into one. (In particular, please don't get the impression that this is building a native, unmanaged executable.) However, I think it's what you're after :)

Update: ILMerge is now open source and is also available as a NuGet package:

Install-Package ilmerge