Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shared NuGet Package Across Multiple Projects and Solutions

What's the current preferred method for setting up NuGet to have a common package directory across all solutions in a project? Also is there a way I can include PCL packages in a common folder across different projects (so that packages can be shared across projects that target different platforms). I've seen similar questions asked before but I cannot find a clear answer that pertains to a recent version of NuGet.

like image 200
user2481095 Avatar asked Apr 06 '16 20:04

user2481095


People also ask

How do I reference an existing NuGet package from a new project?

NET or . NET Core project. After you install a NuGet package, you can then make a reference to it in your code with the using <namespace> statement, where <namespace> is the name of package you're using. After you've made a reference, you can then call the package through its API.


1 Answers

If you include a nuget.config file at a directory which is a common ancestor of all of your solutions, then when you open any those solutions withing Visual Studio it will use this configuration file to configure NuGet.

One of the things nuget.config configures is the location for the nuget packages folder for the solution.

Reference: https://docs.nuget.org/consume/nuget-config-file

Sample nuget.config: note that the repositoryPath is with respect to the location of the nuget.config file.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageRestore>
    <add key="enabled" value="True" />
  </packageRestore>
  <config>
    <add key="repositoryPath" value="packages" />
  </config>
</configuration>
like image 166
Frank Bryce Avatar answered Sep 21 '22 16:09

Frank Bryce