In the latest preview release of Visual Studio we are introducing the ability to disable (or re-enable) the package cache, or move it to another drive. This can be done using the command line or the registry, which can be deployed on a domain using group policy. This will be generally available in Visual Studio in a few weeks – scheduled for the 15.2 update – but we want to give you a preview and collect feedback on the feature.
If you pass
--nocache to the installer – even if just starting the installer – the cache policy is set to disable caching of packages, and any modification or repair of an instance will remove packages that are already cached (except for extensions). You can also pass
--cache to re-enable this policy, which might be handy if you expect to make any changes or repair offline.
"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vs_installer.exe" --nocache
Any install, modify, or repair operation you perform in the Installer will set the policy for any subsequent operation. This means that you only need to pass
--cache) once. The policy is stored in the Windows registry and will be used for subsequent operations.
The policies to disable or move the package cache for Visual Studio 2017 are stored within the Windows registry in the following locations. When checking a particular policy, we will use the first policy value discovered and ignore the remaining keys in the order listed.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\Setup(we will write to this key if the command line operations are specified)
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\Setup(on 64-bit operating systems)
The first registry key above is treated as a read-only key in 15.2 and recommended for administrators deploying group policy objects.
The following registry values are supported.
REG_EXPAND_SZ) The directory where package manifests and, optionally, payloads are stored. The default is “%ProgramData%\Microsoft\VisualStudio\Packages”
REG_DWORD) Keep package payloads even after they are installed. Set to 0 to disable caching packages. The default is 1.
REG_EXPAND_SZ) The directory where some packages shared across versions of instances of Visual Studio are installed. The default is “%ProgramFiles(x86)%\Microsoft Visual Studio\Shared”
If you change the
CachePath after it has already been created, you should move existing packages from the old location to the new location and secure it so that “SYSTEM” and “Administrators” have full permissions, and “Everyone” as read-only permissions.
If you disable the package cache by setting
KeepDownloadedPayloads to 0, any modifications or repairs that require packages will require a connection to the internet or from wherever you installed Visual Studio and packages will be downloaded again. They will be removed after being installed or repaired.
SharedInstallationPath will only affect subsequent installs of shared packages. Any shared packages (like many third-party and some Microsoft packages) already installed will remain where they are.