5

I am working on a .net solution and use nuget for my package management. I have selected the option to "Enable Nuget Package Restore" so that the nuget packages not checked in to source control.

Prior to this I had a nuget.config file at the same level as the solution where I included to following enabling me to specify the location of the nuget packages.

<settings> 
  <repositoryPath>..\Build\NuGetPackages\</repositoryPath> 
</settings> 

Since I enabled the nuget package restore, this is no longer working. I tried to update the config file within the .nuget generated folder but that does not work either.

So where I am going wrong and how can I specify the location of the packages folder?

amateur
  • 43,371
  • 65
  • 192
  • 320

3 Answers3

5

When you enable nuget package restore, there is a NuGet.Config file in the .nuget folder.

Here is a copy showing the path to my libs folder. You can modify yours to match your path. I think its a little cleaner than the already selected answer.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <solution>
    <add key="disableSourceControlIntegration" value="true" />
  </solution>
  <config>
    <add key="repositoryPath" value="../../libs/packages" />
  </config>
</configuration>
Brett Allred
  • 3,459
  • 26
  • 30
2

You can change the next property in your-solution\.nuget\NuGet.targets file:

<PackagesDir>$([System.IO.Path]::Combine($(SolutionDir), "packages"))</PackagesDir>

Or the same property, but in group below if you are using Mono.

Pavel Bakshy
  • 7,697
  • 3
  • 37
  • 22
  • Thanks for this - it was what I was trying but the change was not being picked until I restarted Visual Studio for some reason – amateur Oct 05 '12 at 13:41
2

You should also look at the nuget 2.1 release notes here http://docs.nuget.org/docs/release-notes/nuget-2.1, where there is a new setting added to nuget.config to specify package folder location

<configuration>
  <config>
    <add key=" repositoryPath" value=" C:\myteam\teampackages" />
  </config>
  ... 
</configuration>
Pero P.
  • 25,813
  • 9
  • 61
  • 85
Deepak
  • 2,223
  • 17
  • 15