Andrew Coates ::: MSFT

It's all about community!

What version of TFS am I Running?

What version of TFS am I Running?

  • Comments 5

Chris Birmele, our (ostensibly neutral) VSTS Technical Specialist was complaining about not being able to work out what version (Beta, RC, RTM, SP1) and which Edition (Standard, Trial, Workgroup) of TFS was running on a machine. After consulting with VSTS MVP and all-round TFS guru, Anthony Borton, I was able to point Chris to Rob Caron's article on this very topic.

Chris was less than impressed with having to spelunk through folders and the registry so I whipped him up a command line utility to do his dirty work.

image

Here's the source:

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Diagnostics;
using Microsoft.Win32;

namespace TFSVer
{
    class Program
    {


        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
            Console.WriteLine("TFSVer - Version Information for Team Foundation Server");
            Console.WriteLine();
            Console.WriteLine("Usage: TFSVer");
                return;

            }

            StringBuilder VersionInfo = new StringBuilder("Team Foundation Server Version Information\n==========================================\n");
                                                           
            // go and get the version info
            // based on Rob Caron's Blog Post http://blogs.msdn.com/robcaron/archive/2006/08/15/701843.aspx

            /*
             1. On the application-tier computer, check the file version of Microsoft.TeamFoundation.Server.dll. 
             
             You'll find this file here:

                %PROGRAMFILES%
                  \Microsoft Visual Studio 2005 Team Foundation Server
                    \Web Services
                      \Services
                        \Bin

                Here's the key to determine which release of Team Foundation Server you have:

                8.0.50727.43 = Beta 3 Refresh 
                8.0.50727.127 = Release Candidate 
                8.0.50727.147 = RTM (final shipping release of the product)
                Update: The version number for Visual Studio 2005 SP1 is 8.0.50727.762.
             */

            string DllVersion = "";
            string tfsVersion = "Unrecognised";
            bool RTMorLater = false;
            try 
            {    
                FileVersionInfo TheFile = FileVersionInfo.GetVersionInfo(Environment.GetEnvironmentVariable("PROGRAMFILES") + "\\Microsoft Visual Studio 2005 Team Foundation Server\\Web Services\\Services\\Bin\\Microsoft.TeamFoundation.Server.dll");
                DllVersion = TheFile.FileVersion;
                switch (DllVersion)
                {
                    case "8.0.50727.43":
                    {
                        tfsVersion = "Beta 3 Refresh";
                        break;
                    }

                    case "8.0.50727.127":
                    {
                        tfsVersion = "Release Candidate";
                        break;
                    }

                    case "8.0.50727.147":
                    {
                        tfsVersion = "RTM";
                        RTMorLater = true;
                        break;
                    }

                    case "8.0.50727.762":
                    {
                        tfsVersion = "SP1";
                        RTMorLater = true;
                        break;
                    }

                    default:
                    {
                        break;
                    }

                }
                
                VersionInfo.AppendLine(string.Format("TFS Version: {0}", tfsVersion));

                // now go and find the Edition (If we're in RTM or later)
                if (RTMorLater)
                {
                    /*
                        If you have the RTM release, the next check is to see which edition of Team Foundation Server you have. To do this, open Registry Editor (regedt32.exe) and navigate down to this key:

                        HKEY_LOCAL_MACHINE
                          \SOFTWARE
                            \Microsoft
                              \VisualStudio
                                \8.0
                                  \TeamFoundation
                                    \Registration

                        In this key, you'll find a value named, Edition_CT, which is the clear text equivalent of the encrypted data in Edition. Here's the key to determine which edition you have:

                        "Full" = Team Foundation Server ("Standard Edition") 
                        "Trial" = Team Foundation Server 180-day Trial Edition 
                        "Workgroup" = Team Foundation Server Workgroup Edition 
                     */

                    string Edition = "unknown";
                    string rk = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\VisualStudio\\8.0\\TeamFoundation\\Registration").GetValue("Edition_CT").ToString();

                    switch (rk)
                    {
                        case "Full":
                            {
                                Edition = "Team Foundation Server (\"Standard Edition\")";
                                break;
                            }
                        case "Trial":
                            {
                                Edition = "Team Foundation Server 180-day Trial Edition";
                                break;
                            }
                        case "Workgroup":
                            {
                                Edition = "Team Foundation Server Workgroup Edition";
                                break;
                            }
                        default:
                            break;
                    }

                    VersionInfo.AppendLine(string.Format("Edition: {0}", Edition));

                }
           
            }
            catch (FileNotFoundException fnfEx)
            {
                VersionInfo.AppendLine("TFS Not Installed on this machine");
            }

            Console.WriteLine(VersionInfo.ToString());
            Console.WriteLine("Press any key to continue ...");
            Console.ReadKey();

        }

     }
}

And I've attached the binary project with the binaries in the Release and Debug folders.

As usual, this is a hack without production-level quality control or any exception handling. You'll need to give it sufficient caspol permissions to read the registry and environment variables (I generally copy it to somewhere on the local machine). Use at your own risk.

Attachment: tfsver.zip
  • I tried to convince Andrew to keep this killer feature secret so we can offer it as a $1'000 TFS add-on.

    But like most developers he has no business sense and decided to offer it for free!  So download it as long as you can!

  • Your assumption here is that the TFS dll defines the version for the entire TFS Environment including all databases and all TFS files. Experience has shown that not all installations, upgrades and updates are perfect...

  • Pieter: I agree. It's not designed to be a catch-all, just a tool to automatically do the steps outlined in Rob's article. Feel free to embrace and extend it.

  • Do you need to know what TFS version you are running? Our resident genius Andrew Coates whipped up a

  • Andrew Coates on What version of TFS am I Running? The Accentient Blog on Plug-in to Get Latest on Check-out....

Page 1 of 1 (5 items)