How do you set a relative path for a file-based package source with NuGet?

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.


It looks like this is now supported.

http://nuget.codeplex.com/workitem/2810

  1. 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>
    
  2. Build you packages to the packages-local folder.

  3. 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).

Tags:

Nuget