Question: I've got a VS/TFS2010 project in which we use a generated file. Here's how it works:

1. There's a pre-build event that creates the file (foo.cs)
2. The file is included in the project.
3. The file is NEVER added to TFS version control.

It works great, except... People have an unfortunate habit of accidentally checking in the file. This, of course, breaks the system.

Are there any good ways to prevent this from happening? Can I at least set up some kind of watch mechanism to alert me if it does happen?

Answer: 
You'll need to install the [Team Foundation Server Power Tools](http://aka.ms/tfpt), which will include the "Forbidden Patterns" check-in policy. This will allow you to prohibit a file from being checked in based on regular expression applied to the server path.

This will allow you to simply add the full server path of the file you wish to ensure does not get added. For example:

```
^\$/TeamProject/Folder/foo\.cs$

```
I was researching this exact issue today and found this, which may be of some help: [How to ignore files/directories in TFS for avoiding them to go to central source repository?](https://stackoverflow.com/q/922798/965593)

Not sure if 2010 has made this easier or not.

(Apologies, this should probably be a comment, but I don't think I have enough rep to comment.)