title: How to compile one project into multiple dlls in .NET
body: <p>I am trying to compile one .Net c# project into multiple dlls. But here is the thing.</p>
  
  <p>This is my project structure.</p>
  
  <pre><code>Bin 
  Dir1 
  Dir2 
  File1.cs 
  File2.cs 
  myproject.csproj
  </code></pre>
  
  <p>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.</p>
  
  <p>I used the following:</p>
  
  <pre><code>csc /t:library /out:File1.dll /recurse:*.cs
  csc /t:library /out:File2.dll /recurse:*.cs
  </code></pre>
  
  <p>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?</p>
  
  <p>I want to do this preferably as a part of a post build step in Visual studio.</p>
  
  <p>Thanks for your time... </p>
  
  <p><strong>EDIT</strong></p>
  
  <p>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..</p>
  
  <p>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?</p>
  
  <p>Thanks again for your replies. </p>
  
  <p>cheers.</p>