Excluding Files from TFS Server Workspace

主宰稳场 提交于 2019-12-11 10:29:48

问题


We just implemented TFS in our company and I accidentaly included the bin and obj folders. I would like to exclude them. I searched on Google and found basically 2 ways to accomplish this:

1) https://msdn.microsoft.com/en-us/library/66tw9ezk(v=vs.90).aspx

In Visual Studio, open Solution Explorer and select the file to exclude. On the File menu, click Source Control, then click Exclude from Source Control. When you are ready to place the file under source control, you can access the File menu and click Source Control, then uncheck Exclude from Source Control.

In my File>Source Control, I don't see exclude from source control there or under advanced.

2) How do I permanently exclude the bin and obj folders from TFS 2012 checkin?

I tried adding a .tfignore and I couldn't find the 'ignore by extension', 'ignore file', etc. in teh Promote Candidate Changes dialog box. As far as I understand this is only applies to a local workspace and not a server workspace.

We set up the solution to checkout a file whenever it's altered, so when someone builds the project he acquires an exclusive lock on the dlls and then nobody else is able to compile.


回答1:


After the steps Mike describes, you can go further and define an ignore rule. Undo the pending changes to the file you want to exclude and then click the "detected: 123" link that shows under "Excluded changes".

This open up a new window in which you can ignore these changes indefinitely. It does this by creating a .tfignore file and adding that to source control. The alternative to the UI is t create this file manually and checking it in. This should prevent Team Explorer from showing files that match the patterns in the ignore file.

Make sure that these files are deleted from source control, if they were checked in accidentally, you can destroy them to make sure they are truly gone. You'll need to do this from the commandline using tf destroy

The call to Destroy won't delete your local files when you use the remote itemspec to destroy them:

C:\>tf destroy /collection:http:
//jessehouwing:8080/tfs/DefaultCollection $/Scrum/test.txt.txt /noprompt
Destroyed: $/Scrum/test.txt.txt

C:\Program Files (x86)\Microsoft Visual Studio 14.0>dir "c:\Workspaces\Local\Scrum"
 Volume in drive C has no label.
 Volume Serial Number is 008A-AC5B

 Directory of c:\users\jhouw\Source\Workspaces\Local\Scrum

12-08-2015  20:12    <DIR>          .
12-08-2015  20:12    <DIR>          ..
12-08-2015  20:12                 0 test.txt.txt
               1 File(s)              0 bytes
               2 Dir(s)  297.229.512.704 bytes free

After performing a tf get /collection:http: //jessehouwing:8080/tfs/DefaultCollection $/Scrum /recursive it will indeed be deleted. This should not be an issue if the files in question are regenerated during the next build.

See also:

  • https://stackoverflow.com/a/21260759/736079

If you're using a server workspace, the only way I can think of is to set a Forbidden Path checkin policy for your source control repo. It's a part of the Team Foundation Server Power Tools; you'd need to install the version of the power tools that matches your Visual Studio version on all developers' machines.

Note: these use Regular Expressions, so you'll need to adjust your pattern to match ;).




回答2:


From my personal experience, the easiest way to achieve this is the following:

  1. View -> Team Explorer (Ctrl+\, Ctrl+M)
  2. Click on Pending Changes
  3. In your Included Changes list, right click on the desired folder.
  4. Click Exclude.

The excluded change should now appear in the Excluded Changes list below.



来源:https://stackoverflow.com/questions/31967775/excluding-files-from-tfs-server-workspace

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!