Detecting TFS version/install folder from MSBuild

拟墨画扇 提交于 2019-12-06 07:07:21

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.

  <PropertyGroup>
      <IsTFS2013orHigher Condition="$(TF_BUILD)!=''>Yes</IsTFS2013orHigher>
  </PropertyGroup>

For the install path I would peek the Registry

  <PropertyGroup>
    <TFS2013InstallPath>$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\TeamFoundationServer\12.0@InstallPath)</TFS2013InstallPath>
    <TFS2012InstallPath>$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\TeamFoundationServer\11.0@InstallPath)</TFS2012InstallPath>
    <TFSInstallPath Condition="'$(TFS2013InstallPath)'!=''">$(TFS2013InstallPath)</TFSInstallPath>
    <TFSInstallPath Condition="'$(TFS2013InstallPath)'=='' and '$(TFS2012InstallPath)'!=''">$(TFS2012InstallPath)</TFSInstallPath>
  </PropertyGroup>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!