What is package cache and can you delete it?

Package cache is usually found in C:\ProgramData\Package Cache\ and is the source of installed packages for visual studio and other related products. Microsoft warns against deleting them because these caches contain installer files for various applications on your computer that are useful for repairing, uninstalling, modifying, or reinstalling programs. If you delete the caches, Windows may not be able to carry out these modification operations.

There are two workarounds to the problem:

  1. Disabling the package cache
  2. Moving the package cache
svg viewer

Disable the package cache

If you want the installer to download every package from the internet and then delete it after it is done, you can disable the package cache by running the following command in cmd:

"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vs_installer.exe" --nocache

This is also useful if you want to ensure that all your packages are the latest packages from the internet.

You can re-enable the package cache by passing the --cache argument:

"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vs_installer.exe" repair --passive --norestart --cache

Move the package cache

If you’d like to work offline, you can move the package cache off of your main directory if it is short on space. One way to do this is by transferring the files to any letter drive or NTFS file system (e.g., another mount, hard disk, USB device, and network drive). You will need to create a junction between the old location and the ​new location.

You can create a junction by running:

mklink /J oldpath newpath

Be careful when using relative paths. You can avoid breaking the link as long as you move the link and target together, and maintain their relative paths.

Another way to create a junction is to use this tool. You can read more about the package caches on the official Microsoft docs.

Copyright ©2024 Educative, Inc. All rights reserved