I am trying to compile one .Net c# project into multiple dlls. But here is the thing.
This is my project structure.
Bin
Dir1
Dir2
File1.cs
File2.cs
myproject.csproj
I want to compile this project into File1.dll and File2.dll. Both File1.dll and File2.dll use code in various .cs files that are in Dir1 and Dir2. Some of these classes in the .cs files present in the sub directories are required by File1.cs and the others by File2.cs. There will be some that are used by both File1.cs and File2.cs.
I used the following:
csc /t:library /out:File1.dll /recurse:*.cs
csc /t:library /out:File2.dll /recurse:*.cs
But the resulting dlls were exact copies of each other with just different file names. Is there a way for me to compile them so that when I inspect each dll in the object browser, it has only those classes from the .cs files in the Dir1 and Dir2 that are referenced within File1.cs for File1.dll and similarly for File2.dll?
I want to do this preferably as a part of a post build step in Visual studio.
Thanks for your time...
EDIT
Thanks for all your responses. There were many suggestions for splitting up the solution into many projects. While that is one way to do it, I am not sure if I want the any dependencies created for the two dlls ie File1.dll and File2.dll. Let me explain..
The problem I see with creating multiple projects is that there will be some code that both File1.cs and File2.cs need. I dont want them to be repeated in both projects. Keeping the common code in a third project would mean a third dll will be created that is required for both File1.dll and File2.dll. I dont want this. I want only File1.dll and File2.dll created which is why I am keeping them both in one project. Any suggestions on how to make this happen?
Thanks again for your replies.
cheers.
You need to split your project up into multiple projects within the same solution if you want separate libraries for each component.
You can have the same file included in multiple projects without creating duplicated copies (Add as link
) to avoid issues with duplicated code.