I'm using NuGet 2.1 with multiple solutions, each in a child directory under a single parent directory and a single packages directory which is shared by all the solutions (this became possible with NuGet 2.1).
I'd like to add a file-based package source which points to the packages directory in my working copy (I'm using Subversion).
This works:
<configuration>
<repositoryPath>_Packages</repositoryPath>
<activePackageSource>
<add key="Working copy package source" value="C:\AllMySolutions\_Packages" />
</activePackageSource>
</configuration>
This doesn't:
<configuration>
<repositoryPath>_Packages</repositoryPath>
<activePackageSource>
<add key="Working copy package source" value="_Packages" />
</activePackageSource>
</configuration>
I don't want to hard-code the absolute path but can't find a way of using a relative path in the value attribute inside activePackageSource
.
Open %AppData%\NuGet folder, open existing NuGet. Config file. Edit repositoryPath key and set new destination.
The default is %userprofile%\. nuget\packages (Windows) or ~/. nuget/packages (Mac/Linux). A relative path can be used in project-specific nuget.
It looks like this is now supported.
http://nuget.codeplex.com/workitem/2810
Put a file called nuget.config in the root of your solution (next to packages folder and solution file) containing:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="Local" value="packages-local" />
</packageSources>
</configuration>
Build you packages to the packages-local folder.
The packages in this folder will be available to add to other projects in the solution. (You may need to restart VS or at least close-reopen your solution for the config to be picked up).
I had same problem with <repositoryPath>
. I needed to force all SOLUTIONs in my git repository to use same folder to store their NuGet packages. So I created a nuget.config
file on the root of the repository with the following contents, as it was described in documentations:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="repositoryPath" value="NugetPackages\" />
</config>
</configuration>
After manually creating NugetPackages
beside nuget.config
and installing packages, there was nothing in that directory, but everything was working fine. Then I found that VS has created C:\NugetPackages
and moved packages there. After trial and error for a while, at last the relative path using .\
worked for me:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="repositoryPath" value=".\NugetPackages\" />
</config>
</configuration>
I hope it behaves the same for other configurations as well.
P.S.: As Matthew already said, I had to restart VS to make my edits in nuget.config
take effect.
For .NETCore/.NET5 and newer, the config key repositoryPath
doesn't work anymore, and it is now named globalPackagesFolder
, so:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="globalPackagesFolder" 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