Damian
Damian

Reputation: 2789

Can the NuGet 3.2 package cache location be changed

I have a machine whose C:\ drive has limited space, but I have a large D:\ drive with plenty of space is it possible to change the location of the nuget package cache (I am using nuget 3.x)?

Upvotes: 32

Views: 13282

Answers (3)

John Koerner
John Koerner

Reputation: 38077

Set an environment variable NuGetCachePath with the value of the path where you want the new package cache.

UPDATE: This answer is from 2016 and is no longer relevant for more modern versions of NuGet. As indicated below by @Mohsen the new Environment Variable to set is NUGET_PACKAGES

Environment variable window

Upvotes: 28

Mohsen Afshin
Mohsen Afshin

Reputation: 13436

You can override the default nuget package cache folder by an environment variable:

NUGET_PACKAGES

Reference: Manage Global Packages and Cache Folder

Upvotes: 29

Jorge Costa
Jorge Costa

Reputation: 197

For nuget 3.0 and above I use the following script to redirect the packages folder to a folder in different drive for example for e:\nuget-cache as folder in another drive

pushd %USERPROFILE%\\

rmdir /Q /S .nuget

IF NOT EXIST e:\\nuget-cache mkdir e:\\nuget-cache

mklink /D .nuget e:\\nuget-cache

Upvotes: 12

Related Questions