¿Cómo borrar la caché de paquetes NuGet usando la línea de comandos?


Puedo borrar la caché de paquetes NuGet de mi ordenador de desarrollo usando el botón VS Tools/Options/NuGet Package Manager/General: [Borrar caché de paquetes].

Me gustaría hacer esto en la línea de comandos. Desafortunadamente no puedo encontrar el interruptor de línea de comandos relacionado para nuget.exe.

¿Me he perdido algo?

Author: g.pickardou, 2015-06-19

8 answers

Primero, descargue la herramienta de línea de comandos NuGet desde aquí.

A continuación, abra un símbolo del sistema y cd al directorio en el que se descargó nuget.exe.

Puede listar las cachés locales con este comando:

nuget locals all -list

Puede borrar todas las cachés con este comando:

nuget locals all -clear

Referencia: https://docs.nuget.org/consume/command-line-reference

 440
Author: rm8x,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-11-22 15:24:20

En Visual Studio 2017, vaya a HERRAMIENTAS -> Administrador de paquetes Nuget -> Configuración del Administrador de paquetes. Usted puede encontrar un botón " Borrar todo Caché NuGet (s)" introduzca la descripción de la imagen aquí

Si está utilizando. NET Core, puede borrar la caché con este comando, que debería funcionar a partir de. NET Core tools 1.0:

dotnet nuget locals all --clear

 138
Author: Ricky,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-03-09 01:09:29

El nuget.la utilidad exe no tiene esta característica, pero al ver que la caché de NuGet es simplemente una carpeta en su computadora, puede eliminar los archivos manualmente. Simplemente agregue esto a su archivo por lotes.

del %LOCALAPPDATA%\NuGet\Cache\*.nupkg /q
 81
Author: Kiliman,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-06-19 13:28:38

Para mí tuve que entrar aquí:

%userprofile%\.nuget\packages
 17
Author: Bowofola,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-03-02 15:56:35

Esto se suma a la respuesta de rmoore.

Descargue e instale la herramienta de línea de comandos NuGet.

Lista todos nuestros locales.

$ 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\

Ahora podemos eliminarlos manualmente o, como sugiere rmoore, usar nuget locals all -clear.

 16
Author: Shaun Luttin,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-02-23 17:58:10

Tenga en cuenta que dnx tiene una caché diferente para los resultados http de alimentación

Microsoft .NET Development Utility Clr-x86-1.0.0-rc1-16231
   CACHE https://www.nuget.org/api/v2/
   CACHE http://192.168.148.21/api/odata/

Que puedes borrar con

dnu clear-http-cache

Ahora solo tenemos que averiguar cuál será el comando en la nueva herramienta dotnet cli

...hay

dotnet restore --no-cache
 8
Author: KCD,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-05-26 03:06:38

Si necesita borrar la caché de Nuget para su servidor/agente de compilación, puede encontrar la caché para los paquetes de Nuget aquí:

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

Ejemplo: C:\Windows\ServiceProfiles\NetworkService\AppData\Local\NuGet\Cache

 5
Author: khablander,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-05-12 07:13:05

Puede usar powershell para (igual que yo).

Por ejemplo:

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

O modo 'silencioso' (sin mensajes de error):

rm $env:LOCALAPPDATA\NuGet\Cache\*.nupkg 2> $null
 3
Author: honzakuzel1989,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-04-05 14:42:58