Determining the version of TFS using the TFS object model
If you are building an extension using the TFS object model that is going to target multiple versions of TFS, you would most likely want to programmatically figure out the version of the TFS Server you are currently pointing at. Some of the API services introduced in the later version of TFS aren't available in earlier versions of TFS. Unfortunately, the API does not expose a property or function that will give you the exact version of TFS. In this recipe, you'll learn how to determine the TFS version programmatically.
Getting ready
Follow the steps in the Acquiring TFS object model from the NuGet Gallery recipe to create a project in Visual Studio. Name the project DetermineTFSVersion
and add the TFS NuGet packages to this project.
How to do it...
Copy the following code into the
Program.cs
class in the newly created project.In the
Main
method, add the following code:var server = new TfsTeamProjectCollection(new Uri("http://tfs2015:8080...