Saturday, April 11, 2020

Configure NuGet Cache Directories

Powershell snippets to change where nuget caches packages. As they are, these lines will add a machine-wide environment variable.

[System.Environment]::SetEnvironmentVariable('NUGET_PACKAGES', 'D:\nuget\packages', [System.EnvironmentVariableTarget]::Machine)
[System.Environment]::SetEnvironmentVariable('NUGET_HTTP_CACHE_PATH', 'D:\nuget\v3-cache', [System.EnvironmentVariableTarget]::Machine)
[System.Environment]::SetEnvironmentVariable('NUGET_PLUGINS_CACHE_PATH', 'D:\nuget\plugins-cache', [System.EnvironmentVariableTarget]::Machine)
For more https://docs.microsoft.com/en-us/nuget/consume-packages/managing-the-global-packages-and-cache-folders