nugetnuget-packagenuget-server

how to specify location of nuget packages when package restore is enabled?


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?


Solution

  • You can change the following 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.