Can I delete the folder C:\ProgramData\Package Cache\?

425

120

There is a new folder full of installers located at C:\ProgramData\Package Cache\. I believe this is from Visual Studio 2012 RC.

Can I delete these gigabytes of data without consequences? Are they all temporary files? It's a beta product so I'm not sure there is much information out there about this folder.

Ben L

Posted 2012-07-31T14:47:34.373

Reputation: 4 610

See my answer below. After uninstalling Visual Studio it had left this directory behind. I deleted it and have had no problems. In my answer I say YES is the answer. – SDsolar – 2017-06-03T11:00:16.897

4I would suggest against anything that's more than 50MB in size, it's used for something. Try moving them to your desktop or something, running it, and if it crashes, move them back. – Jon – 2012-08-04T03:13:18.233

1I can't really test my original scenario but I recall that everything uninstalled fine. Since there are several people saying they have had issues, I've revoked the accepted answer. Keep in mind that I was using 2012 RC. – Ben L – 2013-11-13T23:47:51.420

@BenL even though I understand when you say "I can't really test my original scenario but I recall that everything uninstalled fine. Since there are several people saying they have had issues, I've revoked the accepted answer." I think my answer below (the most popular one so far) allows anyone, in any case, to work around the issue by moving and pointing the folder to a drive with more space. It will even work with offline media. So, you can simply remount/insert your archive DVD/reconnect your external drive, if that's where you move this too, at the time of uninstall, repairs, etc. – Flak DiNenno – 2014-02-02T15:09:52.363

1@FlakDiNenno I like your workaround. But the question is about if it's safe to delete, not if it's safe to mount or offline. – Ben L – 2014-02-03T16:12:39.567

@BenL Good point. I've added some detail and a link from Microsoft that definitely recommends that you DO NOT delete the folder and why. – Flak DiNenno – 2014-02-16T00:28:15.113

Answers

395

TL;DR: Do NOT delete this folder

(see below for workarounds)


Why Not?

There have been conflicting reports about whether the absence of this folder (as a consequence of deleting it) will actually and in all cases cause issues with the visual studio installation, i.e. during normal operation, during reinstall, patch/upgrade, repair install, or uninstall. However, the recommendation from MICROSOFT is clearly to NOT DELETE IT.

From Microsoft Developer Tools Blogs → HERE

When repairing, modifying, or uninstalling a product or when installing or uninstalling a patch, if source media is required the package cache is used automatically and most users will never see a prompt. Only if the package cache is missing or incomplete will Visual Studio setup prompt to download (if connected) or locate media as shown in the screenshot below.

Visual Studio 2012 Prompt for Source

Users who have installed from media even get the option to download (if connected). So while very few customers should ever see this dialog, we wanted to make sure the experience was easy.
Even though we will prompt to download packages to the cache if missing, we recommend users do not remove the package cache. Not only is the cached used by many other products that are installed with Burn and may not provide the same download experience, there are scenarios when Windows Installer may require source that we cannot handle because our code is not running.


Solution/Work-Around:

If you need to reclaim this space, your safest bet is to avoid "deleting" anything, but to instead, move this folder and all it's files. You can safely do this following the instructions below to any local/live, online, near-line, or offline storage as long as that storage system that can be mounted to a drive letter or any mount point on the NTFS file system. Any of the following will work:

  • another live (mounted) partition
  • an optical disc (CD, DVD, etc.) with a live filesystem like FAT, or NTFS
  • an external hard drive
  • a USB drive
  • a network drive

Whenever you are prompted for the media/receive any errors about missing files/missing location, you simply make sure to remount/reinsert your drive/media if it's not already a live partition.

Once moved, in order to "link" the old mount point/location (in most cases C:\ProgramData\Package Cache\), you simply create a directory junction to it.

Junctions are recognized at the file systemlevel as an alias entry in the FSTAB. Therefore, it's transparent to all programs, including the OS itself. In other words, it is NOT seen as a file that simply points to another location (like a shortcut) and therefore always works without incident.

  1. You would move the folder(s) in question to its new location
  2. Create the junction

    • Option 1. (natively): Just issue the built-in Windows Vista / 7 / 8 command and the cmd prompt:

      mklink /J oldpath newpath
      

      NOTE: If you make the newpath absolute, you'll be able to move link without breaking the pointer to the newpath. If you make the newpath relative, you'll be able prevent breaking the link, as long as you move BOTH the link and target TOGETHER and maintain their relative paths.

    • Option 2. (using a tool): Another GREAT alternative is a free handy utility I've been using for years called "Link Shell Extension". LSE is free and you can find it here (or Google for it): http://schinagl.priv.at/nt/hardlinkshellext/hardlinkshellext.html

      LSE allows you to create symlinks, hardlinks, junctions, smartcopies, smartclones, smart mirrors, smart moves, splices, multiple sources, and bunch of other stuff I found too confusing to read, frankly. But, it's a brilliant free product that creates a Windows Explorer context menu that allows you right-click on your LINK-TARGET folder then drag it to where you'd like to create the actual link. You can of course rename the link to anything you'd like.

Flak DiNenno

Posted 2012-07-31T14:47:34.373

Reputation: 4 450

2I'm thinking if a needed package is not in the cache, VS will download it. So I'm going to just delete it. I'll update this comment later if I run into issues. – toddmo – 2016-01-06T16:33:42.153

164Dear Microsoft: Please do not use the name "cache" to describe a folder that causes this much headache when deleted. Thanks. – Todd Menier – 2016-05-11T23:27:54.157

9Did the trick with moving to another drive and making a junction. Running VS2015 SP3 installer today, the installer caused the junction to devolve to a normal directory (possibly when uninstalling an older version of some component, it recursed through "empty" parent directories removing them -- there are known problems with junctions and naive empty directory tests). So it placed new components in C:\ProgramData\Package Cache and then failed to find items in the new location where the junction formerly pointed. Just a warning to future readers the junction may need to be re-established. – Ben Voigt – 2016-07-19T21:15:25.730

5As a more permanent fix, use NTFS permissions and deny "delete" permission on the junction itself. – Ben Voigt – 2016-07-19T21:15:42.793

1So I have this friend cough who deleted this folder, is there a way to regenerate the PackageCache? The linked blog post does mention this, but does not go into detail.. – kadrach – 2016-08-01T04:34:43.560

1I'm very confused about the absolute/relative comments. if i'm moving it to another drive then surely it has to be absolute? I also don't know what 'move the link and target together' means. I just cut and paste to another drive and did mklink /J "c:\programdata\Package Cache" "s:\package cache"and it all worked fine - but can someone elaborate on the absolute/relative comment for me. thx – Simon – 2016-08-31T00:36:00.637

@Simon I'll try to help, but, sorry which comment exactly are you referring to. thnx. – Flak DiNenno – 2016-09-01T09:32:35.060

Another Microsoft blog post discusses this topic and mentions the need to maintain file/folder permissions when relocating this folder. The blog post describes using a VHD, but a subsequent comment by the author claims using a junction point is valid, too. But the ACL's need to be accounted for. See https://blogs.msdn.microsoft.com/heaths/2014/02/11/how-to-relocate-the-package-cache/

– MikeOnline – 2016-09-06T21:08:31.940

2The only reason I know of this folder's existence is because I'm trying to uninstall VS 2013 using the Programs and Features panel, and while the dark box that says "Visual Studio" comes up, no uninstaller ever arrives. So, curious what the item in the Programs and Features list was even pointing to, I looked for it on disk and found these package caches. I can't uninstall OR install VS as of now (and the version that's installed isn't launching), so I think deleting this folder is my last resort before I have to do a clean install of Windows to get going again. – bubbleking – 2016-09-16T14:42:32.630

@bubbleking: Please, please come back to us and tell if zapping the monster had resolved the deadlock! – Sz. – 2016-09-19T13:50:08.137

@Sz. - Nope. It just made the items kind of disappear from Programs and Features as though they were already uninstalled, but some of them stayed and just didn't have their icons anymore. Truth be told this was a system where several versions of SQL Server and VS had been installed and removed. Before putting on SQL Server 2016 and VS 2015 Update 3, I wanted to start with a clean slate. I thought I'd probably need to just clean install Windows, but first I tried using Total Uninstaller to remove the myriad VS/SQL packages I never used. The uninstallers weren't working, nor were the... – bubbleking – 2016-09-19T14:19:27.717

@Sz. - installers. After using Total Uninstaller, nothing got better. Like I said, I'll just need to install Windows fresh. This time, though, I'm older and wiser and know which bloaty packages I don't need to install from VS and SQL Server. – bubbleking – 2016-09-19T14:21:03.427

@bubbleking: Thanks for checking back with the update, much appreciated! – Sz. – 2016-09-22T12:48:47.213

1Just to share a failed tip: I tried compressing the folder contents and the results are almost nothing. Not worth trying, this is already compressed. – pgr – 2017-04-08T15:38:36.683

1If you have removed Visual Studio the YES you can delete this leftover directory. See my answer below. – SDsolar – 2017-06-03T11:02:14.560

4

This seems now outdated. See https://docs.microsoft.com/en-us/visualstudio/install/disable-or-move-the-package-cache

– 0xA3 – 2018-05-28T07:56:24.247

21this is great solution. i need to cleanup my SSD c drive by moving files to other drive. many thanks – marek – 2013-08-15T16:34:39.307

7+1 for Hardlink Shell Extension. Couldn't live without it. – Dennis G – 2013-12-15T12:47:21.287

1@BenL even though you "can't really test my original scenario but I recall that everything uninstalled fine. Since there are several people saying they have had issues, I've revoked the accepted answer." I think my answer above allows anyone in any situation to get around the issue in all cases. – Flak DiNenno – 2014-02-02T15:06:24.690

49

I've found the same folder on my laptop after installing VS2012. I tried renaming that folder to '__Package Cache'. When I then tried to uninstall VS2012 the uninstall process failed to start.

More information is available here.

Claudio Valerio

Posted 2012-07-31T14:47:34.373

Reputation: 591

23

The correct answer seems to be that if you delete it, VS 2012 will fail to uninstall, but it is otherwise not needed. Therefore:

  1. You can leave the files there. Everything will work but it will use lots of disk space.
  2. You can delete the files, and if you want to uninstall VS 2012, you can re-run the original installer to put the files back, then uninstall.
  3. You can move the files to another drive with more free space and either:

    a) move the files back when you need them

    b) create a junction as in Flak's suggestion (warning: junctions are tricky beasts, and will lie to Windows Explorer telling you the files take up disk space on C: when they are really on another drive!)

Junctions and symbolic links are the only answer for moving system files to another drive. They are NTFS filesystem-level features that even Windows itself is oblivious to, and thus are a really big hammer (and potential security risk) that should be used sparingly unlike their UNIX/Linux/BSD counterparts, since they have been around a lot longer on that OS family and UNIX/Linux/BSD programs know how to deal with them.

Jonathan Baldwin

Posted 2012-07-31T14:47:34.373

Reputation: 426

2junctions are tricky beasts, and will lie to Windows Explorer telling you the files take up disk space on C - if what you mean by this is that when you open the properties dialog of the junction, it displays the "Size on disk" equal to its size on the disk it actually is in, then I agree that it is misleading. But however, actual the size of the folder being junctioned doesn't add up to the total used space on the C drive as displayed by properties dialog of C drive. In that case your statement is misleading ;-) – Sнаđошƒаӽ – 2017-03-18T10:14:17.493

19

For Visual Studio 2017, you can disable the package cache (even after Visual Studio is installed) by calling:

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

I gained about 2 GB of disk space on my system drive from that (YMMV).

For details, see the docs: Visual Studio Docs: Disable or Remove the Package Cache

0xA3

Posted 2012-07-31T14:47:34.373

Reputation: 692

Has anyone tested disabling and removing the cache after vs2017 is installed? – Ben L – 2018-05-29T18:04:55.287

1@BenL: It worked for me. – 0xA3 – 2018-05-30T16:10:03.420

1This seems to be the proper way of deleting the Package Cache folder. Only thing is, calling is not enough: you actually have to execute an action through the installer (such as upgrading or reinstalling visual studio). – rsenna – 2018-12-21T09:46:49.327

2By moving the VS package cache I did manage to save a lot of space on the primary drive, but I don't think it answers this question. The folder which ended up virtually empty as a result of moving the VS package cache was C:\ProgramData\Microsoft\VisualStudio\Packages, not C:\ProgramData\Package Cache. – Peter Taylor – 2019-11-08T10:00:45.347

17

All the software's installers are saved in this folder. It would fail when you try to uninstall a software after deleting this folder.

ahjzysq

Posted 2012-07-31T14:47:34.373

Reputation: 171

12

I noticed this folder after I installed Visual Studio 2012, in my case everything in it contained to the Visual Studio 2012 installation, I manually removed it and everything seems to be working including Visual Studio.

Johan Svensson

Posted 2012-07-31T14:47:34.373

Reputation: 261

7This is the accepted answer and it is wrong. If you delete this folder you won’t be able to uninstall or update Visual Studio (and related tools and redistributables — this will cause security issues if an update to MSVC runtimes comes out) – kinokijuf – 2013-07-13T12:05:50.553

6You're wrong, I have without any problem managed to update Visual Studio 2012 with the latest updates. Thanks. – Johan Svensson – 2013-08-09T09:16:34.187

7

YES you can delete this directory, if you have uninstalled Visual Studio.

I found this directory after uninstalling Visual Studio in preparation for installing a SSD smaller than the hard drive I was using before. This computer is no longer a development station.

Uninstalling Visual Studio left behind some other software like a program to connect to a local SQL server, which I do not have. I uninstalled it.

It also left behind several .NET programs but I don't know which ones are safe to uninstall so I left them in place.

So to the point of the question: I did delete this directory.

It was quite large so helped me to fit into my SSD better.

Now a day later I haven't noticed any problems.

SDsolar

Posted 2012-07-31T14:47:34.373

Reputation: 1 206

6Months later, still no problems. – SDsolar – 2017-10-02T04:01:50.637

7

No. If you delete this folder, you won’t be able to uninstall (and possibly update) Visual Studio.

kinokijuf

Posted 2012-07-31T14:47:34.373

Reputation: 7 734

1

It's usually better not to mess up with deleting these files manually, and instead leave this task to either Windows Disk Cleanup, or other disk cleaning tools. The one I personally use and can recommend you is the CCleaner.

CCleaner can help you automatically find obsolete files in a program and deletes them for you.

Prahlad Yeri

Posted 2012-07-31T14:47:34.373

Reputation: 841

4CCleaner is just crappy more or less. I had to restore my computer (due to not be able to start) after trying using this tool. Better not never use it. – Hopeless – 2015-11-16T13:38:32.153

13Be very careful; these programs are by no means foolproof. CCleaner has been known to remove files critical for some programs to run, and some options will remove files kept for uninstallation. – Bob – 2012-11-16T11:53:03.937