0

I have a class library with a bunch of classes and I would like to compile each of my classes into its own assembly. Is that possible?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Brandon Michael Hunter
  • 1,179
  • 3
  • 20
  • 48

3 Answers3

3

It is possible. A separate assembly is created when you compile your solution for each project that exists in Visual Studio, so you only need to create a project per class to obtain what you want.

Having said that, I am not sure that having one assembly per class is a good thing to do. Loading assemblies at run-time is expensive, and managing them at design-time requires some effort too. Would you care to elaborate on why you need such a thing?

CesarGon
  • 15,099
  • 6
  • 57
  • 85
  • I would like, in a single project, to compile each class into its own assembly, and not into one assembly. I don't want to create a seperate project for each class, but just have one project with multiple classes where it will produce assemblies. – Brandon Michael Hunter Jun 23 '10 at 18:20
  • The answer is simply no, then. What you want to do is not possible. Maybe the resulting single assembly can be later split into multiple assemblies using third-party tools. – CesarGon Jun 23 '10 at 18:21
  • Is there a way to write a bat file to do this on post-build? – Brandon Michael Hunter Jun 23 '10 at 18:27
  • The problem is not the bat file, but finding the third-party tool that would split an assembly into multiple ones. – CesarGon Jun 24 '10 at 19:17
3

You might have to do some msbuild gymnastics but this might get you started on your way.

Stack Overflow - Visual studio one project with several dlls as output?

Community
  • 1
  • 1
MotoWilliams
  • 1,538
  • 1
  • 12
  • 22
2

I would have to guess your real question is "can it be done automatically?" No, you have to create a project for each assembly. Quite a maintenance and deployment nightmare with no easily conceivable advantages.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536