How to exclude a file from TFS source safe in Visual Studio?
Often you want to include a file into one of your Visual Studio projects, but you do not want to check it in TFS. Such files can be for example .css files generated from sass or less files or JavaScript files created automatically after TypeScript files are compiled.
Visual Studio provides a way to perform this task. Unfortunately it is not as easy as it sounds…
Do the following steps:
-
Include the file into your project. From Visual Studio you can click the Show All Files button in the Solution Explorer area and then you can also see the files that are physically in the same folder as the project, but do not yet belong to the project. Find the file you want to include and do a right-click on it and select the Include In Project option. The file is now included in your project and was also added in the “Pending Changes” list of TFS. Read the third point to see why this is an important information.
-
Open the file in Visual Studio and click on the FILE tab in the Visual Studio main menu. Then Source Control -> Advanced -> Exclude ………. from Source Control. Look at the Solution Explorer again, your file now has the STOP sign as icon which means that it will be excluded from TFS. You can also see in the Pending Changes that the .csproj.vspscc file is checked out. This file contains the excluded files of the current project.
-
Unfortunately you are not ready yet. Your excluded file is also checked out from TFS and waits to be checked in as a pending change. Of course that is exactly what we do not want to avoid. Go to your Source Control Explorer and navigate to the folder that contains the excluded file. From there right-click on the file and delete it. Now you are 100% sure that the file is really excluded and is not going to be checked in.
I hope that these three steps have helped you.