前言
由于C盘的空间有限,NuGet的包位置默认又在C盘,这就很烦,只能去自己手动修改
NuGet 配置文件位置
配置文件共有三处,添加下面的内容即可 (高版本可以设置环境变量解决)
<-- 添加下面的键值即可 -->
<config>
<add key="globalPackagesFolder" value="E:\nuget" />
</config>
C:\Users\NueXini\AppData\Roaming\NuGet\NuGet.Config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
<config>
<add key="globalPackagesFolder" value="E:\nuget" />
</config>
</configuration>
C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="Microsoft Visual Studio Offline Packages" value="C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\"/>
</packageSources>
<config>
<add key="globalPackagesFolder" value="E:\nuget" />
</config>
</configuration>
C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.FallbackLocation.config
<?xml version="1.0" encoding="utf-8"?>
<!--<auto-generated>
This code was generated by a tool.
Changes to this file may cause incorrect behavior and will be lost if
the code is regenerated.
</autogenerated>-->
<configuration>
<fallbackPackageFolders>
<add key="Microsoft Visual Studio Fallback Folder" value="D:\Microsoft Visual Studio\2019\Shared\NuGetPackages" />
</fallbackPackageFolders>
<config>
<add key="globalPackagesFolder" value="E:\nuget" />
</config>
</configuration>
NuGet 环境变量
使用 NUGET_PACKAGES
环境变量代替 globalPackagesFolder
或 repositoryPath
使用 NUGET_HTTP_CACHE_PATH
环境变量替代http-cache
使用 NUGET_PLUGINS_CACHE_PATH
环境变量替代plugins-cache
查看所有文件夹位置dotnet nuget locals all --list
清除所有缓存dotnet nuget locals all --clear
其他问题
-
如果你不知道你的默认配置文件在哪里,请查阅
https://learn.microsoft.com/zh-cn/nuget/consume-packages/configuring-nuget-behavior -
还能配置更多参数,请查阅
https://learn.microsoft.com/zh-cn/nuget/reference/nuget-config-file -
如果不想修改设置,可以设置环境变量
https://learn.microsoft.com/zh-cn/nuget/consume-packages/managing-the-global-packages-and-cache-folders文章来源:https://www.toymoban.com/news/detail-680756.html -
NuGet命令行用法 (cmd/powershell 输入
dotnet nuget
)
https://learn.microsoft.com/zh-cn/nuget/reference/nuget-exe-cli-reference文章来源地址https://www.toymoban.com/news/detail-680756.html
到了这里,关于Visual Studio 2022修改NuGet包的缓存位置的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!