简体   繁体   English

NuGet 3.2 包缓存位置可以更改吗

[英]Can the NuGet 3.2 package cache location be changed

我有一台机器的 C:\\ 驱动器空间有限,但我有一个很大的 D:\\ 驱动器有足够的空间是否可以更改 nuget 包缓存的位置(我使用的是 nuget 3.x)?

Set an environment variable NuGetCachePath with the value of the path where you want the new package cache.使用您希望新包缓存所在的路径的值设置环境变量NuGetCachePath

UPDATE: This answer is from 2016 and is no longer relevant for more modern versions of NuGet.更新:此答案来自 2016 年,不再与更现代的 NuGet 版本相关。 As indicated below by @Mohsen the new Environment Variable to set is NUGET_PACKAGES正如@Mohsen 所示,要设置的新环境变量是NUGET_PACKAGES

环境变量窗口

You can override the default nuget package cache folder by an environment variable:您可以通过环境变量覆盖默认的 nuget 包缓存文件夹:

NUGET_PACKAGES

Reference: Manage Global Packages and Cache Folder参考: 管理全局包和缓存文件夹

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对于 nuget 3.0 及更高版本,我使用以下脚本将包文件夹重定向到不同驱动器中的文件夹,例如 e:\\nuget-cache 作为另一个驱动器中的文件夹

pushd %USERPROFILE%\\

rmdir /Q /S .nuget

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM