Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find the path to tf.exe from MsBuild

I have an MsBuild file which shells out to TFS using tf.exe for a few things. Unfortunately the tf.exe file has been installed to different locations on the developer PCs and the build server.

I could really do with a way of detecting where the tf.exe file is located within my script in the same way you can do $(MSBuildExtensionsPath32) etc. Is this possible?

Thanks as always :)

like image 736
Chris Surfleet Avatar asked Aug 08 '11 07:08

Chris Surfleet


People also ask

What is TF exe?

You can use version control commands to do nearly all tasks you can do in Visual Studio, and also several tasks that can't be done in Visual Studio. You can use the tf.exe tool to run version control commands from a command prompt or within a script.


2 Answers

Does the environment variable VS100COMNTOOLS point to the correct path for visual studio? E.g. VS100COMNTOOLS=C:\Program Files\Microsoft Visual Studio 10.0\Common7\Tools\

So then all you need is $(VS100COMNTOOLS)..\IDE

<Target Name="Build">    <Exec Command="&quot;$(VS100COMNTOOLS)..\IDE\tf.exe&quot;"/> </Target> 

or however you want to tidy it up.

The environment variable changes depending on the version of Visual Studio:

  • %VS110COMNTOOLS% - Visual Studio 2012
  • %VS120COMNTOOLS% - Visual Studio 2013
  • %VS140COMNTOOLS% - Visual Studio 2015
like image 148
James Woolfenden Avatar answered Sep 19 '22 11:09

James Woolfenden


Seems they changed location again in Visual Studio 2017. It was not in any of the above locations on my machine.

I found TF.exe instead at:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer

(Some users may find in the Professional folder instead of Enterprise folder: C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\tf.exe)

Apparently the environment variable is no longer set by default in VS 2017.

like image 35
BautaBear Avatar answered Sep 20 '22 11:09

BautaBear