I wish to call the GetBuildProperties task from my MSBuild script run on TFS. However, this script can be run on either TFS 2010 or TFS 2013. Is there a way to detect the version of TFS that has launched an MSBuild Script? At the moment, I am getting around the problem like so:
<PropertyGroup>
<CurrentProgramFiles>$(ProgramW6432)</CurrentProgramFiles>
<CurrentProgramFiles Condition="$(CurrentProgramFiles) == ''">$(ProgramFiles)</CurrentProgramFiles>
</PropertyGroup>
<PropertyGroup Condition="$(TeamFoundationServerUrl)!='' and Exists('$(CurrentProgramFiles)\Microsoft Team Foundation Server 2010')">
<TeamBuildRefPath>$(CurrentProgramFiles)\Microsoft Team Foundation Server 2010\Tools</TeamBuildRefPath>
</PropertyGroup>
<PropertyGroup Condition="$(TeamFoundationServerUrl)!='' and Exists('$(CurrentProgramFiles)\Microsoft Team Foundation Server 12.0')">
<TeamBuildRefPath>$(CurrentProgramFiles)\Microsoft Team="" Foundation Server 12.0\Tools</TeamBuildRefPath>
</PropertyGroup>
<UsingTask
TaskName="Microsoft.TeamFoundation.Build.Tasks.GetBuildProperties"
AssemblyFile="$(TeamBuildRefPath)\Microsoft.TeamFoundation.Build.ProcessComponents.dll"
Condition="$(TeamFoundationServerUrl)!=''" />
Starting with TFS 2013 you have some interesting variables, not previously available TF_BUILD environment variables. So you can use TF_BUILD to know if you are using 2013, like this.
For the install path I would peek the Registry