visual-studio 如何从 TFS 控制下的项目中删除空文件夹?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3462340/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to remove a empty folder from a project under TFS control?
提问by KentZhou
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.
假设我有一个项目 MyLib,在该项目下,我创建了一个文件夹,比如 Folder1。此文件夹下没有文件。该项目已连接到 TFS。
Then I want to remove this folder Folder1. I deleted it from context menu and checked the project into TFS.
然后我想删除这个文件夹Folder1。我从上下文菜单中删除了它并将项目签入 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!
然后我用Team Explore->Source Control检查TFS上的数据,Folder1被删除了。但它仍然存在于本地计算机上的 VS 2010 中。我关闭了 VS 2020 并从寡妇探索中删除了 Folder1。然后再次打开VS 2010,Folder1还在。我无法从 MyLib 本地删除它!
Confused. How to resolve this problem?
使困惑。如何解决这个问题?
回答by sra
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.
只需在文件夹中创建一个文件,然后将其与新文件一起删除即可。当您尝试删除空文件夹时,TFS 会遇到一些问题。
回答by Daniel Weisel
Do the following:
请执行下列操作:
In Visual Studio, open "Solution Explorer".
Right-click on the project in question, and select "Unload Project".
Right-click on the unloaded project (should be grade out), and choose "Edit (Project)".
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).
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.
Save changes, and close the Editor.
Go back to Solution Explorer, right-click on the grayed-out project, and choose "Reload Project".
Compile and check-in the project. Make sure you delete the physical folder from Windows Explorer (if it's still there).
在 Visual Studio 中,打开“解决方案资源管理器”。
右键单击有问题的项目,然后选择“卸载项目”。
右键点击卸载的项目(应该是分级出来的),选择“编辑(项目)”。
在 XML 编辑器(刚刚打开)中搜索有问题的文件夹名称(CTRL+F 调出“搜索”窗口,并在当前文档中搜索文件夹名称)。
搜索完成后,它应该在 XML 编辑器中突出显示包含文件夹名称的 XML 节点(大多数情况下它位于一个节点中,它告诉 Visual Studio 在项目的编译中包含有问题的文件夹(通过 MSBuild ))。只需删除包含文件夹名称的节点即可。
保存更改并关闭编辑器。
返回解决方案资源管理器,右键单击变灰的项目,然后选择“重新加载项目”。
编译并签入项目。确保从 Windows 资源管理器中删除物理文件夹(如果它仍然存在)。
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
由 Hakam Fostok 编辑:如果您的项目在 TFS 下,那么在应用前面的步骤后,您可能需要打开 Source Controler Explorer 并从那里删除文件夹
回答by user588035
If you right click on the project and select edit project file, you can then delete the entry for the offending folder. After you save and reload the project, you can then delete the folders from your hard drive and then source control.
如果右键单击项目并选择编辑项目文件,则可以删除违规文件夹的条目。保存并重新加载项目后,您可以从硬盘驱动器中删除文件夹,然后再进行源代码控制。
回答by Jehan33
You can try doing Get Specific version. Right Click parent Folder of the file in Source Control and choose Get Specific version.It will open Get window, here choose Type as Latest Version and check the both available Check box options.
您可以尝试执行获取特定版本。右键单击源代码管理中文件的父文件夹并选择获取特定版本。它将打开获取窗口,在这里选择类型为最新版本并选中两个可用的复选框选项。
回答by Jehan33
Sorry for the late reply, I missed to check your reply.
抱歉回复晚了,我错过了查看您的回复。
The above error suggests that the folder may be Checked out & locked by some other user.
上述错误表明该文件夹可能已被其他用户签出并锁定。
In Source Control, are you able to see the Status of the folder as Checkout & lock?
在源代码管理中,您能否看到文件夹的状态为 Checkout & lock?
If yes,can you use Status Sidekick of TFS Sidekicks tool and try to unlock the folder (http://www.attrice.info/cm/tfs/).
如果是,您能否使用 TFS Sidekicks 工具的 Status Sidekick 并尝试解锁文件夹(http://www.attrice.info/cm/tfs/)。
Then, try to delete the folder again.
然后,再次尝试删除该文件夹。
回答by Alan Feng
I tried the solution that to add a new file then delete the folder with the file but failed.
我尝试了添加新文件然后删除包含该文件的文件夹的解决方案,但失败了。
My solution was to delete the physical folder first, then sign-in the code to TFS. (You will see the change list include the deletion of the folder.)
我的解决方案是先删除物理文件夹,然后将代码登录到TFS。(您将看到更改列表包括文件夹的删除。)
After sign-in, you will be able to delete the folder in your solution explorer.
登录后,您将能够删除解决方案资源管理器中的文件夹。
回答by t_plusplus
Just create a file in it (a class file for example) - check in, then after it checks in (successfully) - delete and it will do.
只需在其中创建一个文件(例如一个类文件) - 签入,然后在签入(成功)之后 - 删除它就可以了。
So simply put: check in and then delete and it will work..
所以简单地说:签入然后删除,它会工作..
回答by MacMerg
Here's what you do: Make a physical folder with the same name in the correct directory of your project. Check everything in. Once they get synched you'll be able to delete the folder from vs and check your program in again.
您可以这样做: 在项目的正确目录中创建一个具有相同名称的物理文件夹。检查所有内容。一旦它们同步,您就可以从 vs 中删除该文件夹并再次检查您的程序。

