Creating single assembly from multiple projects


I have created a solution containing number of projects. When I am building the solution, all the projects are building individually and for each project individual dlls are created in bin folder. I need to know if there is a way so that I can create a common dll/exe which i can give to client. I donot want to give so many dlls to my client. Also I donot want to create a setup/deployement project.

Any ideas????
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

pg_indiaAuthor Commented:
Just to give an example I have a solution containing 3 projects. When i build them 3 different bin folders are created. I need a single dll/exe for it to work.
you need to combine all three projects into a single project. What does your three projects do? do they all compile to a DLL?

Why not create a single project and seperate the three projects into folders with their own namespaces?

pg_indiaAuthor Commented:
Well thats a good solution to do but my client has a specific format of divinding a solution into different project.. so I cannot combine them intoa  single project and different folders.

any other solution is needed!!
OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

There is another way, but you need to use the external compiler, you can't do it via Visual Studio:

lets say I have 3 projects, project1/2/3, on the command window, I open each of the project folders and call:

  csc /t:module project1.cs

this will create the file: project1.netmodule

once I have done this for all 3 projects I then call:

  csc /addmodule:project1.netmodule /addmodule:project2.netmodule /addmodule:project3.netmodule

Hope that helps
Just for reference, if you're aiming to produce a library only the syntax is:

  csc /t:library /out:SingleFile.dll /addmodule:Project1.netmodule /addmodule:Project2.netmodule /addmodule:Project3.netmodule

'csc' = C Sharp Compiler
'/t' = the target to be a library file (default is an exe) (in the above bit where we created netmodules we set the type to be module)
'/out' = the filename for the output dll
'/addmodule'  = adds the given module to the compiled output.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Oh and one more :)

If you're projects have more than one file (i.e. Project1 has class1.cs and class2.cs files), you compile it like so:

   csc /t:module class1.cs class2.cs

(think i'm done now!!)
imo, if it made sense to break the solution up into three different projects then it surely makes sense to break the assemblies up into three different projects!  i dont understand the rational behind needing to combine.
Distribution is one of the main reasons to combine the dlls, but there are others:

  1. It enables each project to be written in a different language - you can combine vb,c#,c++ netmodules together,
  2. You can optimize the CLR by putting related types in the same dll, so they are all loaded into memory at the same time,
      - seldom used types are in another module, which is loaded when needed, providing a smaller footprint (obviously this can backfire).
  3. You can included data only modules (xml, images, sound etc) (using AL.exe -- Assembly Linker)

I'm interested!

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.