How to setup single Nuget packages folder for multiple solutions and projects in Visual Studio 2015

前端 未结 1 667
灰色年华
灰色年华 2021-02-19 04:33

We are developing multiple solutions in Visual Studio 2015. The solutions share some core projects that need nuget packages. The nuget references cannot be resolved when the nug

相关标签:
1条回答
  • 2021-02-19 05:01

    To resolve the issue, we put a NuGet.config file into the Codebase directory then deleted all the other Nuget.config files and .nuget folders in the solutions. Since NuGet configurations are propagated to sub folders, the settings in the single NuGet.config file are applied into all the solutions.

    Inside the Nuget.config file we put the packageSource, repositoryPath settings.

    Example NuGet.config file:

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <config>
            <add key="repositoryPath" value="./SharedPackages" />
        </config>
    </configuration>
    

    Existing nuget packages need to be uninstalled and reinstalled since the dll references in .csproj files will still show the old packages folder. Or you can manually edit the .csproj files.

    Resulting folder structure:

    • Codebase folder
      • Nuget.Config file
      • SharedPackages folder
      • SharedProjects folder
        • SharedProject1
      • SolutionA folder
        • WebProjectA
        • packages folder A
      • SolutionB
        • WebProjectB
        • packages folder B
    0 讨论(0)
提交回复
热议问题