Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can new projects in VS2017 store nuget packages in project packages director?

Through automatic nuget restore is convenient it is not safe. I previously checked in all packages into the repository. This was easy as VS created a packages directory under the project root.

Now I find I have a

~/.nuget 

directory outside the project hierarchy. Is there a way to revert the behavior? Perhaps a flag in the *.csproj file?

like image 845
bradgonesurfing Avatar asked May 09 '17 11:05

bradgonesurfing


1 Answers

You can change the location for the global package folder to a solution-local location by specifying a path in a NuGet.Config file next to the solution (note that you have to re-open the solution for this to have an effect):

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <config>
    <add key="globalPackagesFolder" value=".\packages" />
  </config>
</configuration>

There are two properties that can be set this way to affect the location of where the packages will be restored to. repositoryPath for packages.config projects and globalPackagesFolder for project.json and projects usingPackageReference.

like image 82
Martin Ullrich Avatar answered Sep 16 '22 22:09

Martin Ullrich