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.
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.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With