.NET Power Tip 7: Excluding Files from TFS Source Control (Detected: 500 Add(s))

Sometimes you need a directory or some files within your Visual Studio Solution that you do NOT want to check-in into TFS Source control.

However, Visual Studio will detect the files and Team Explorer will show you that there are detected changes:

image

These files are not only annoying but also confusing to some developers.

Using a “.tfignore” file you can instruct TFS to ignore these files.

If you are using TFS2012 you need to manually create the file. If you are using TFS2013 you can create it via context menu (find instructions below).

Just include a file that is called “.tfignore” into a folder. It will be in effect for the current folder and all its children. However, you can create another file in a subfolder that will undo the effect of the first file.

An example file could look like this:

image

More details can be found here:

https://msdn.microsoft.com/en-us/library/ms245454.aspx?f=255&MSPPError=-2147217396#tfignore

If you are using TFS2013 you can use the context menu to create the file. Just open the team explorer and click on the “Detected: 505 Add(s)” link. This will open the “Promote Candidate Changes” dialog.

In this dialog, right clicking one or multiple items will open the context menu where you can exclude files by name, extension or folder.

image

This action will create a .tfignore file for you:

image

You can now go ahead and modify the file to your needs.

With this file in place, whenever you add files to a folder outside of visual studio, Team Explorer will just ignore them.