Sharing files has some advantages and disadvantages. It is nice to be able to have a common file that is referenced throughout your code base. That shared file might contain a version number, or some useful constants. Sharing is pretty common in web development scenarios I believe as well.
The tricky thing about sharing a single file across multiple projects is that by default Visual Studio will make copies of any existing files that you try to add to your project. That’s good for isolating yourself from breaking changes, but not so good if you’re trying to share a single copy of a file.
I stumbled across a feature in Visual Studio last night that makes this type of sharing pretty easy to do. When you have a project open in Visual Studio and you want to add an existing file, you can use the Add Existing Item context menu option. In the resulting dialog you can navigate to a file and add it to your project. Visual Studio, by default, will create a copy of that file and put it in your project folder.
However, there is an additional option to add just a reference to that file as illustrated below:
This Add As Link option enables you to setup single-file sharing with Team Foundation Server. If you add links to a shared file from several different projects, each of those projects will see any change you make to that shared file immediately.
Again, this type of sharing is not always the right thing to do, but it is an option. I recorded a short video that illlustrates how to combine this feature with Team Foundation Server to enable sharing.