How to remove a empty folder from a project under TFS control?

Suppose I have a project MyLib, under that, I created a folder say Folder1. No file under this folder. The project is connected to TFS.

Then I want to remove this folder Folder1. I deleted it from context menu and checked the project into TFS.

Then I check the data on TFS with Team Explore->Source Control, Folder1 is deleted. But it is still there in VS 2010 on local computer. I closed VS 2020 and deleted Folder1 from widows explore. Then open VS 2010 again, the Folder1 is still there. I can't remove it locally from MyLib!

Confused. How to resolve this problem?


Solution 1:

Simply create a file within the folder and delete it along with the new file. TFS has some problems with empty folders when you try to delete them.

Solution 2:

Do the following:

  1. In Visual Studio, open "Solution Explorer".

  2. Right-click on the project in question, and select "Unload Project".

  3. Right-click on the unloaded project (should be grade out), and choose "Edit (Project)".

  4. In the XML Editor (that just opened) search for the problematic folder name (CTRL+F to bring up the "search" window, and search in current document for the folder name).

  5. When the search is done, it should highlight in the XML Editor the XML Node that contains the folder name (most of the times it is in a Node that tells Visual Studio to include the folder in question in the compilation of the project (via MSBuild)). Just delete the node that contains the name of the folder.

  6. Save changes, and close the Editor.

  7. Go back to Solution Explorer, right-click on the grayed-out project, and choose "Reload Project".

  8. Compile and check-in the project. Make sure you delete the physical folder from Windows Explorer (if it's still there).

Edit By Hakam Fostok: if your project under TFS, then after applying the previous steps you may need to open the Source Controler Explorer and delete the folder from there also