22

I want to ignore a folder (and its content) in a visual studio 2015 solution from beeing checked-in into tfs.

I created a file called '.tfignore' in the root of the project that is containing the folder I want to exclude.

The content of the file looks like this: /Dist

This is not working at all. Even if I add *.cs to the file, nothing gets excluded.

Does somebody know where the problem is? How do I wire this up in a working way?

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
evaenrique
  • 981
  • 2
  • 8
  • 17
  • Are you using a local workspace or a server workspace? – Daniel Mann Apr 21 '16 at 21:47
  • I don't fully understand the question. I am working on the project on my local machine. The project is checked in into TFS. As soon as I finished a feature, I check it into TFS. Is that, what you ask? – evaenrique Apr 22 '16 at 08:15
  • And there is an option in VS "[X] Apply .tfignore when adding files to project" that could be unchecked... – Christoph Feb 26 '20 at 16:39

3 Answers3

37

First, please make sure your .tfignore file created without any problem. This file does not have any suffix. One way to create it suggest you to rename a new.txt file with "tfignore." It will auto change to right .tfignore file.

You can also use the auto automatically generated .tfignore file, follow below steps:

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

pending changes, Detected changes link , which counts the number of adds, in this case 50003 add(s) (I have a busy directory clearly!)

The Promote Candidate Changes dialog box appears.

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

the promote candidate changes dialog opens. right-clicking an item in its list includes options like "Ignore by extension *.js"

  1. Choose OK or Cancel to close the Promote Candidate Changes dialog box.
  2. 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 is automatically created by Visual Studio  and appears in pending changes with the "add" notation, suggesting you will commit it

More info please check the Customize which files are ignored by version control from MSDN Link:Add files to the server

Nate Anderson
  • 18,334
  • 18
  • 100
  • 135
PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
  • Thank you very much for your explanation. But even if I create the file with the assistant you have described, I have no luck. I excluded everything with the ending *.cs, but it changed nothing. I am sure my syntax is correct (since I have used the assistant and then simply changed the ending to cs). All my new .cs files are still listed under "included changes". Any thoughts? – evaenrique Apr 22 '16 at 09:00
  • 3
    This .tfignore file will not affect with those files already in source control. Make sure your .tfignore files have checked in source control. Try to close your VS and clear TFS and VS chache follow this https://blogs.msdn.microsoft.com/vsalm/2013/12/17/how-to-clear-the-tfs-cache-on-client-machines/ Then try it again. – PatrickLu-MSFT Apr 22 '16 at 12:34
  • 4
    To create this file, after a number of attempts !, I used the command prompt.. echo jaysusTheyMakeThingsComplicated > .tfignore – bbsimonbb Apr 26 '16 at 09:40
  • see also https://www.visualstudio.com/en-us/docs/tfvc/add-files-server#tfignore-file-rules – Matej May 09 '17 at 11:10
3

If your .tfignore file is in the solution root folder, adding a \Dist to it will make TFS ignore the Dist folder only inside the root folder. For instance, if you create a Dist folder inside a subfolder (e.g any of the projects folder in the solution), it won't work.

In that case, you need to use just Dist rather than \Dist, then rule will aply to the .tfignore root folder and all its subfolders.

This only apply to folders.

Alisson Reinaldo Silva
  • 10,009
  • 5
  • 65
  • 83
2

Your file path slash is the wrong kind of slash, it should be a backslash \.

\Dist
Adrian Thompson Phillips
  • 6,893
  • 6
  • 38
  • 69
  • 1
    Actually, if you take a look into an autogenerated ```.tfignore``` file, you will see the following note in it: ```The / character is interpreted as a \ character on Windows platforms.``` – uncoder Jan 04 '18 at 17:56