visual-studioversion-controlreference

Best way to reference an external library in multiple projects in a Visual Studio solution


We have a Visual Studio 2008 solution under VSS source control. The solution contains many class libraries, many of which need a reference to an assembly that is not part of the solution. Currently we are keeping separate copies of that assembly in each project but as the number of projects grows it gets increasingly tedious to copy in updates to the external assembly. Is there a better way to have a single copy of the assembly in the solution, and in source control, that can then be referenced in all the projects?


Solution

  • Create an "external libraries"/"lib"/"libraries" folder in root folder, add it to source control and reference libraries in projects from there. With "Copy local" in reference properties project will automatically copy it to it's bin folder.

    Structure of our project:

    workspace
      config
        partial app configs goes here
      lib
        external libraries goes here
      src
        Domain          
          domainProjects
        Infrastructure
          infrastructureProjects
            references 3rd party dll's from lib folder
        UI
        Tests        
      solutions
        primaryUIapplication
          references projects from "src" folder
        domainLogic
        etc.
    

    In solution it looks like:

    _misc
      config
      tests
    Domain
    Infrastructure
    UI