David Colwell David Colwell - 11 months ago 93
C# Question

Build output reference assemblies to subfolder


My assembly (a DLL) is being loaded by a third party application, I have no control over how it is loaded. The third party app will load all assemblies in a given directory.


If my assembly and another assembly use the same library, but different versions, they will both be in the same directory and will conflict. I have already researched the

config file directive, and Assembly Resolvers, so I know how to create a subdirectory and have my assembly search it for references.


I need some way of configuring visual studio to build my main DLL into the root folder, and all references into a subfolder. Preferably during build (since I configured my build to go directly to the correct folder.

Answer Source

You can put your references in a separate folders. Here is how:

  • Add a folder to your project root.

enter image description here

  • Rename folder to appropriate name.

enter image description here

  • Right-Click on folder and from Add -> Existing Item

enter image description here

  • Now select & add any reference assembly to this folder. You can add files as a link

  • Right-Click References and go to Add Reference -> Browse

  • Navigate to your newly created folder and select assemblies.

  • Set Copy to Local to True for each Reference.

  • Build your project.