views:

154

answers:

6

Is it possible to force my C# solution file to make a single DLL containing all the projects in the solution, instead of one DLL per project? This dude says that isn't possible but I notice that's a post from 2004. I'm using Visual Studio 2008 Team System and it's a C# application.

+9  A: 

No. Each project will compile into a separate library or application.

You can, however, merge these together into a single DLL or EXE file using ILMerge post compilation.

Reed Copsey
A: 

It is possible, and it was even possible in 2004.

However, Visual Studio does not expose it.

You need to use netmodules.

SLaks
Are you sure? That looks like it creates a multimodule assembly (one assembly that uses multiple dlls), not a single dll.
Don Kirkby
It's still a single DLL.
SLaks
A: 

You could create an MSBuild script that uses XSLT to combine all of the csproj files into one and then builds it. You won't need to copy cs files or anything like that, just dynamically generate a new csproj file.

Sam
+3  A: 

It is not possible with Visual Studio directly, but you can merge assemblies using ILMerge. This could e.g. be done in a post-build step:

ilmerge /target:winexe /out:SelfContainedProgram.exe 
    Program.exe ClassLibrary1.dll ClassLibrary2.dll

If your project is an ASP.Net project you can rely on the ASP.NET Merge Tool.

0xA3
A: 

Never done it personally but looks like this tool could make that happen:

ILMerge

brendan
+1  A: 

I use NuGenUnify after the fact to combine multiple DLLs (and the exe) into a single EXE. It uses the ILMerge utility under the hood. I would expect that you could make a custom build action that would use the utility and combine the DLLs under most conditions without too much trouble.

tvanfosson