20

I have a warning message that came to dinner but now won't leave.

Multiple packages failed to uninstall. Restart Visual Studio to finish the process.

enter image description here

Unfortunately, however, restarting Visual Studio has no effect—the warning remains.

I've tried cleaning the solution as well as the project; all of my projects' assembly references are intact. I've also issued an Update-Package -Reinstall command—which succeeded—to no avail.

How can I set about fixing this?

InteXX
  • 6,135
  • 6
  • 43
  • 80
  • 6
    Have you set your packages under the source control? If yes, please try to remove the packages from source control and instead using NuGet Package Restore. If not, please try to delete the entire ~\packages folder, then restart Visual Studio and Restore. – Leo Liu Apr 17 '17 at 02:23
  • @Leo-MSFT — FYI I'm using the `repositoryPath` configuration, so as to centralize my packages in my dev environment (no SCC). But anyway, I believe this may have been caused by a File Explorer folder lock. I received a similar warning later, this time for a specific package; because I now knew which package it was I was able to use [Lock Hunter](https://lockhunter.com/) to discover why it wasn't deleted. I closed File Explorer, restarted VS, and the warning was no longer present. The original warning—the subject of this Q&A—was gone the next day, after having signed out and back in to Windows. – InteXX Apr 17 '17 at 19:20
  • Glad to know that you have find the reason and resolved this issue. Could you please convert your comment to answer and mark it answer which is benefit to other communities who has the same problem? Thanks. – Leo Liu Apr 18 '17 at 02:05
  • @Leo-MSFT — Done. Thanks for the suggestion; I probably wouldn't have done so otherwise. – InteXX Apr 18 '17 at 04:46

6 Answers6

10

I believe this may have been caused by a File Explorer folder lock.

I received a similar warning later, this time for a specific package; because I now knew which package it was I was able to use Lock Hunter to discover why it wasn't deleted.

I closed File Explorer, restarted VS, and the warning was no longer present. The original warning—the subject of this Q&A—was gone the next day, after having signed out and back in to Windows.

InteXX
  • 6,135
  • 6
  • 43
  • 80
7

I tried resetting permissions on the packages folder various different ways. Reset the owner, reset all child permissions, added my user account to permissions with full control etc... Tried killing Explorer process to release locks on files.

None of that worked.

What did work was to delete the entire contents of the packages folder (made a backup first) and let Visual Studio restore all the packages the next time I loaded it.

Richard Moore
  • 1,133
  • 17
  • 25
4

This was a permission issue within the packages folder for me. Used a PS script to determine if files were locked or with other errors such as access denied; changed the permissions and restarted visual studio. All was good afterwards.

Here is the PS script used: Check for locked files in Directory and find locking applicaiton

Changed the gci command to include -Recurse.

bitwit
  • 41
  • 2
4

In my case it was due to files that were under source control, were not checked out, and so could not be deleted/updated..

If you look in the Output window, and select Package Manager, then it will show you a list of the problem files that can then be manually checked out in TFS/source control.

Chris H
  • 501
  • 1
  • 4
  • 11
  • 1
    the solution was to check those nuget's file in to TFS (even though they were marked as missing, with small yellow triangle icon) and then install the nuget. – curious.netter Mar 12 '20 at 09:56
1

In my case, I had a shared project open in multiple solutions at the same time. Closing the other Visual Studio with the shared project fixed the issue.

InteXX
  • 6,135
  • 6
  • 43
  • 80
sinnerjo
  • 11
  • 2
0

I get this persistently, and cannot find what is locking the folder contents. However, the following one-liner on the windows command line solves it for me fairly simply:

for %i in (c:\mypath\myproject\packages\*.deleteme) do rmdir /q /s %~pi%~ni & del %i

This works by finding all the .deleteme files, deleting the matching folder, then deleting the .deleteme file itself. This doesn't seem to have any problems with permissions or locking, even on a non-administrator command line.

To see what this is going to do first:

for %i in (c:\mypath\myproject\packages\*.deleteme) do @echo rmdir /q /s %~pi%~ni & @echo del %i

Resulting in, for example:

rmdir /q /s \mypath\myproject\packages\JsonSubTypes.2.0.1
del c:\mypath\myproject\packages\JsonSubTypes.2.0.1.deleteme
rmdir /q /s \mypath\myproject\packages\Microsoft.Bcl.AsyncInterfaces.6.0.0
del c:\mypath\myproject\packages\Microsoft.Bcl.AsyncInterfaces.6.0.0.deleteme

One easy reusable solution is to build this into a batch file which takes a parameter, remembering to double up the % signs:

@echo off
for %%i in (%%1\*.deleteme) do echo rmdir /q /s %%~pi%%~ni & echo del %%i

Save that in your solution folder, then just drag-drop the packages folder onto it.

This would also be easy to automate with something like the Command Task Runner extension.

Geoff
  • 8,551
  • 1
  • 43
  • 50