views:

42

answers:

3

When I 'Remove' a project from a Visual Studio solution I often want to delete it. As some other posts on SO have mentioned this does not delete the physical project from the file system.

The larger problem here is that after removing the project form the solution when I attempt to delete the directory from windows Explorer or the command line it will not delete because Visual Studio still has it locked.

Usually, I am able to resolve this by exiting Visual Studio then doing the delete. But, occasionally I have had to log off and back on before being able to delete the directory.

I have had this problem in VS2008, VS2010 and probably the earlier versions as well.

My question is, if there is no way to do this delete from inside Visual Studio, is there at least a way to get it to let go of the file(s) that it has locked?

+3  A: 

You could use Process Explorer, which allows you to close specific handles a program is holding onto. Just open it up, find the Visual Studio process (devenv.exe), use View/Lower Pane View/Handles, locate the proper handle in the lower pane, right-click it and choose "Close Handle". May not be ideal, but sometimes this is better than closing your app or killing the process.

Justin Pinkley
Thank you for the suggestion, I did not know that Process Explorer would do that. That is definately an improvement over having to log out of Windows.
Jim Reineri
+1  A: 

Besides devenv.exe which goes away when you close Visual Studio, you might try killing mspdbsrv.exe. It will restart as soon as an instance of Visual Studio needs it.

DougN
Thank you for that suggestion, I did not know about that process.
Jim Reineri
+1  A: 

You could use a tool like Unlocker to unlock the files.

Jim G.