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?
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
.
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