Sharing files in Team Foundation Server

Hey guys,

As you probably know, sharing is not a feature that is supported by Team Foundation Server.  Buck Hodges’ and Brian Harry have both made some excellent posts about this.

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:

Addaslink

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.

Thanks!

Eric.

Comments

  • Anonymous
    July 21, 2006
    Buck Hodges on removing the Team Foundation Server association in Microsoft Project and Microsoft Excel...
  • Anonymous
    December 10, 2006
    I recieved some email: Subject: Visual Studio Team Foundation Source Control Best Practices Hi Charles,