David Colwell
David Colwell

Reputation: 2590

Build output reference assemblies to subfolder

Background

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.

Problem

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 <probing> config file directive, and Assembly Resolvers, so I know how to create a subdirectory and have my assembly search it for references.

Need

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.

Upvotes: 6

Views: 6246

Answers (1)

raidensan
raidensan

Reputation: 1139

You can put your references in 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.

Upvotes: 4

Related Questions