简体   繁体   中英

TFS Path for commandline tools to use in MSBuild

It it my understanding that it is still the simplest to use the <Exec \\> MSBuild task and shell to TF.exe in order to TFS command line during MSBuild, especially if you don't want to create a dependency on custom build tasks or extension packs etc. (see Checkout from TFS with MSBuild )

Given that, what is the best path to use for tf.exe especially since different developers may have TFS2010 or TFS2012 mixed with VS2010 and VS2012 and also mixed with 64-bit workstations.

Is there parhaps a variable / path standard way to call the TF.exe command from MSBuild regardless of VS or TFS version?

You can see if a system is 64-bit by looking for the ProgramW6432 environment variable.

And as long as users have chosen the default install path, TF.exe is still installed in the 32-bit part of Visual Studio even for VS2012. So the only thing you should need to look for is whether the user has 2012 or 2010 installed. That should be possible with the Exists condition:

<PropertyGroup>
  <ProgramFiles32 Condition="$(ProgramW6432) != ''">$(PROGRAMFILES) (x86)</ProgramFiles32>
  <ProgramFiles32 Condition="$(ProgramFiles32) == ''">$(PROGRAMFILES)</ProgramFiles32>

  <VS10Dir>$(ProgramFiles32)\Microsoft Visual Studio 10.0</VS10Dir>
  <VS11Dir>$(ProgramFiles32)\Microsoft Visual Studio 11.0</VS11Dir>

  <TF Condition="Exists('$(VS10Dir)')">&quot;$(VS10Dir)\Common7\IDE\TF.exe&quot;</TF>
  <TF Condition="Exists('$(VS11Dir)')">&quot;$(VS11Dir)\Common7\IDE\TF.exe&quot;</TF>
</PropertyGroup>
...
<Exec Command="$(TF) checkout ..."></Exec>

tbergstedt has a solution is likely more robust and can be adapted to other problems too. I did discover that there is a shortcut for this, since the TF.exe executable is also in the Developer Environment path $(DevEnvDir) . See below:

  <PropertyGroup>
    <TfCommand>&quot;$(DevEnvDir)\tf.exe&quot;</TfCommand>
  </PropertyGroup>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM