30

I mucked around with TFS settings and I accidentally included the bin and obj folders for TFS 2012 checkin, and even checked them in already. I don't want this because these files change often and aren't meant for inclusion.

I've checked What happened to "Exclude from Source Control" in VS2012. The accepted answer doesn't work because the bin & obj folders and the DLLs inside those folders don't appear in the "Promote Candidate Changes" list, even after excluding them. The second most popular answer also doesn't work permanently. I press yes to all and it removes them from the included changes list, but when I do any action involving rebuilding, they're added to include list again.

I'm looking for a permanent solution which will permanently exclude these folders and the files inside from checkin, and if possible also removes them from the TFS server.

Community
  • 1
  • 1
Nzall
  • 3,439
  • 5
  • 29
  • 59
  • 1
    possible duplicate of [How to ignore files/directories in tfs?](http://stackoverflow.com/questions/922798/how-to-ignore-files-directories-in-tfs) – Lukas Eder Nov 25 '14 at 09:10
  • @nate-kerkhofs - you haven't marked an answer, which is a bit rude. The answer provided by jessehouwing works and fulfils the requirements you specified. – Bertie Dec 09 '14 at 15:59
  • @Bertie I replied myself with an answer later, and I couldn't get the .tfignore solution to work. – Nzall Dec 09 '14 at 20:41
  • @NateKerkhofs - my bad, didn't notice that post was by you. Epic fail! :) Did you ever get to the bottom of why you couldn't create the ignore file? Did that point to something a little more suspect?! – Bertie Dec 11 '14 at 11:44
  • @Bertie I don't know really, and I can't test it anymore because I no longer work there, so I have no access to a TFS server to test it with. – Nzall Dec 11 '14 at 16:14
  • @NateKerkhofs - Bum! Some sort of file permissions, maybe different level of VS or TFS maybe? Ahh well - hope you're having trouble free development in your new job! ;) – Bertie Dec 12 '14 at 10:00
  • The thing with this answer is that you can't ignore a file/folder once it's already promoted. – RHPT Jul 30 '15 at 15:50

3 Answers3

31

TFS 2012 has the option to drop a .tfIgnore file in your workspace.

Visual studio has a UI to create the file for you:

While you can manually create a .tfignore text file using the above rules, you can also automatically generate one when the Pending Changes page has detected a change.

To automatically generate a .tfignore file

  • In the Pending Changes page, in the Excluded Changes section, choose the Detected changes link.

  • The Promote Candidate Changes dialogue box appears.

  • Select a file, open its context menu, and choose Ignore this local item, Ignore by extension, or Ignore by file name.

  • Choose OK or Cancel to close the Promote Candidate Changes dialog box.

  • A .tfignore file appears in the Included Changes section of the Pending Changes page. You can open this file and modify it to meet your needs.

  • The .tfignore file is automatically added as an included pending change so that the rules you have created will apply to each team member who gets the file.

Or create it from the command line using echo . > .tfIgnore and then open it using notepad.

Another trick is to name the file .tfIgnore. in explorer and save it. You'll probably be prompted if you want to change the extension, the answer, in this case, is: yes.

Community
  • 1
  • 1
jessehouwing
  • 106,458
  • 22
  • 256
  • 341
  • 3
    so I just add a .tfignore file in the root with \bin and \obj in there? – Nzall Jan 21 '14 at 14:27
  • 2
    Yes, make sure it is part of your workspace. You can check in the file if you want to. – jessehouwing Jan 21 '14 at 14:28
  • how do I add a file without a name? Both when I try using explorer and add-new item from quick menu, I cannot add a .tfignore file because it needs a name. – Nzall Jan 21 '14 at 14:32
  • Added the ways to create the file from the ui or from the commandline. – jessehouwing Jan 21 '14 at 15:07
  • 1
    Under-rated answer. Follow the instructions @jessehouwing has described and you have a sure fire ignore list. Easy to do - I recommend using the Pending Changes route he described. – Bertie Dec 09 '14 at 15:56
  • Ignore list istn really supposed to work like that. It is more for having a file in TFS but excluding it from checkin at the local machine. Like web.config (But honestly, I never even got that working) To remove file completely from checkins, make sure you remove the directory from source control(not delete), check in, and then delete the files/dir from `Source Control Explorer` and checkin in Source Control Explorer. Now TFS doesnt know about the files and wont compare them because they are not source controlled neither are they missing! – Piotr Kula Jun 02 '15 at 11:57
  • 2
    FYI, `.tfignore` follow the `.gitignore` syntax where there is much more documentation.... – Philippe Aug 21 '15 at 15:07
12

For Excluding Bin folders ,Tick "Show Solution Changes" Under View options in "Included Changes"

Anoosh Rahman
  • 121
  • 1
  • 2
6

I called in the help of our TFS admin.

We couldn't make a .tfignore file, but what did work was the following:

  1. Check in both folders in TFS;
  2. Delete the dlls and pdbs which are unique to the project from the source control explorer and check in this change.
  3. Rebuild the project locally, try to check in and confirm that there are no pending changes.

the dependent assemblies remain in TFS, but since these rarely change, this isn't a big issue.

Nzall
  • 3,439
  • 5
  • 29
  • 59
  • 2
    This is a good answer. The reason is that `Source Control Explorer` is the bit which makes sure the files checked in at some time, exist in the solution and get checked in again. In Visual Studio, the check in happens as a `Client` - So even though the folder is not under Source Control, TFS is saying the files must be checked in. TFS is a beast and having the server and client managemnet in VS confuses allot of people since they think it is the same thing. The `.tfsignore` thing.. never worked for me ever, as supposed to work with `web.config` – Piotr Kula Jun 02 '15 at 12:00