如何使用命令行清除NuGet包缓存?

本文介绍了如何在命令行中清除NuGet包缓存。由于nuget.exe工具本身不提供此功能,可以通过手动删除相关文件夹或使用特定的批处理命令来实现。提到了使用`nuget locals all -clear`命令以及通过PowerShell删除缓存的方法,并提供了NuGet缓存的默认路径。
摘要由CSDN通过智能技术生成

本文翻译自:How to clear NuGet package cache using command line?

I can clear my dev computer's NuGet package cache using VS Tools/Options/NuGet Package Manager/General: [Clear Package Cache] button. 我可以使用VS Tools / Options / NuGet Package Manager / General:[Clear Package Cache]按钮清除我的开发计算机的NuGet包缓存。

I would like to do this in command line. 我想在命令行中执行此操作。 Unfortunately I can not find related command line switch for nuget.exe. 不幸的是我找不到nuget.exe的相关命令行开关。

Did I miss something? 我错过了什么?


#1楼

参考:https://stackoom.com/question/25n9p/如何使用命令行清除NuGet包缓存


#2楼

The nuget.exe utility doesn't have this feature, but seeing that the NuGet Cache is simply a folder on your computer, you can delete the files manually. nuget.exe实用程序没有此功能,但是看到NuGet Cache只是计算机上的文件夹,您可以手动删除这些文件。 Just add this to your batch file. 只需将其添加到批处理文件中即可。

del %LOCALAPPDATA%\NuGet\Cache\*.nupkg /q

#3楼

First, download the NuGet command line tool from here . 首先,从这里下载NuGet命令行工具。

Next, open a command prompt and cd to the directory to which nuget.exe was downloaded. 接下来,打开命令提示符并cd到下载nuget.exe的目录。

You can list the local caches with this command: 您可以使用以下命令列出本地缓存:

nuget locals all -list

You can clear all caches with this command: 您可以使用此命令清除所有缓存:

nuget locals all -clear

Reference: https://docs.nuget.org/consume/command-line-reference 参考: https//docs.nuget.org/consume/command-line-reference


#4楼

This adds to rmoore's answer. 这增加了rmoore的答案。

Download and install the NuGet command line tool. 下载并安装NuGet命令行工具。

List all of our locals. 列出我们所有的当地人。

$ nuget locals all -list
http-cache: C:\Users\MyUser\AppData\Local\NuGet\v3-cache
packages-cache: C:\Users\MyUser\AppData\Local\NuGet\Cache
global-packages: C:\Users\MyUser\.nuget\packages\

We can now delete these manually or as rmoore suggests, use nuget locals all -clear . 我们现在可以手动删除它们,或者如rmoore所建议的那样,使用nuget locals all -clear


#5楼

You can use powershell to (same as me). 你可以使用powershell(和我一样)。

For example: 例如:

rm $env:LOCALAPPDATA\NuGet\Cache\*.nupkg

or 'quiet' mode (without error messages): 或'安静'模式(没有错误消息):

rm $env:LOCALAPPDATA\NuGet\Cache\*.nupkg 2> $null

#6楼

If you need to clear Nuget cache for your build server/agent you can find cache for Nuget packages here: 如果您需要为构建服务器/代理清除Nuget缓存,可以在此处找到Nuget包的缓存:

%windir%/ServiceProfiles/[account under build service runs]\\AppData\\Local\\NuGet\\Cache

Example: C:\\Windows\\ServiceProfiles\\NetworkService\\AppData\\Local\\NuGet\\Cache 示例:C:\\ Windows \\ ServiceProfiles \\ NetworkService \\ AppData \\ Local \\ NuGet \\ Cache

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值