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.