13

I have been looking for the TF.exe command line equivalent to git reset. I found TFPT scorch, however this is for use on a build server (jenkins), and I cannot seem to get the power tools installed (in a standard manner) or working (non standard, copy across).

Is there either

  1. A way to install tfpt.exe on a build server (that does not, and must not, have visual studio)?
  2. A way to emulate this command with a collection of TF.exe commands?
major-mann
  • 2,602
  • 22
  • 37
  • I don't understand -- how do you have `tf` if you can't install Visual Studio? The requirements between `tf` and `tfpt` should be the same, no? – Edward Thomson Dec 05 '13 at 18:29
  • You are able to copy tf (see the second comment at http://stackoverflow.com/questions/5503858/how-to-get-tf-exe-tfs-command-line-client), however in this case I am using Team Explorer Everywhere (which is a basically a java tf supplied by MS that is cross platform) http://www.microsoft.com/en-us/download/confirmation.aspx?id=30661 – major-mann Dec 05 '13 at 20:18
  • I see from your profile you are familiar with the software :P – major-mann Dec 05 '13 at 20:20
  • I gotcha. I don't think there's an easy way to do a scorch equivalent with just the `tf` command line client. – Edward Thomson Dec 05 '13 at 20:29
  • Darn... thanks anyway for your time :) – major-mann Dec 05 '13 at 20:30
  • If you're open to writing some code and want to use the TEE SDK, you could roll your own? – Edward Thomson Dec 05 '13 at 20:38
  • I'll have a look... my boss is out for a few days... so maybe i can sneak it in :) ... i was thinking something along the lines of folderdiff... undo... ????... profit? – major-mann Dec 05 '13 at 20:47
  • I created an answer about how to drive the SDK. You may be able to folderdiff your working directory against the workspace version in order to get the list of files that should be deleted. It depends on if you want to write batch scripts or java...! I'll make a note that we should include `scorch` as a `tf` command in TEE CLC. – Edward Thomson Dec 05 '13 at 21:24
  • Wow! What a result... Normally I would jump on the idea to code it... but my new job has me setting up a CI server (on windows) so batch scripts will probably be the way to go... its a bank holiday here tomorrow, so I will have a look at it on Monday... thanks! – major-mann Dec 05 '13 at 21:41

4 Answers4

26

You don't specify which version of TFS you are using. However, there is an equivalent: tf reconcile /clean.

As per the tf documentation:

Microsoft (R) TF - Team Foundation Version Control Tool, Version 12.0.30501.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Compares the current state of the workspace on disk with the server's view,
either to clean the workspace or to promote unpended local changes.

tf reconcile /clean [/diff] [/noprompt] [/preview] [/recursive] [/ignore]
             [/unmapped] [/exclude:itemspec1,itemspec2,...] [itemspec]

tf reconcile /promote [/adds] [/deletes] [/diff] [/noprompt] [/preview]
             [/recursive] [/noignore] [/exclude:itemspec1,itemspec2,...]
             [itemspec]

Running: tf reconcile /clean /diff /noprompt /recursive *.*

Is equivalent to: tfpt scorch *.* /noprompt /recursive /deletes /diff

Interesting fact is that this command is absent from current tf.exe documentation.

Also, as @Jonathan mentions, there is now a tf scorch command as well which is eerily similar to tf reconcile. If there are differences, I cannot find the documentation to back it up. It's very possible it has something to do with working with Local vs. Server workspaces, which was added in 2013 to allow true "offline" development.

Sumo
  • 4,066
  • 23
  • 40
2

I install TFPT automatically in my build agent install script:

msiexec /qb /i "tfpt.msi" ADDLOCAL=CLI /l*v tfpt-log.log

And then find it easily using the TFSPowerToolDir env var. Update: This does require Visual Studio - I install a subset of it, just vs_teamExplorer.exe and vstf_testagent.exe.

Also, tf.exe now has a /scorch option as well. It wasn't there in VS2013, but it's there in VS2013 SP4.

Jonathan
  • 6,939
  • 4
  • 44
  • 61
1

If you're open to writing your own "scorch" functionality, you can do so against the TFS Java SDK, which does not require you to install Visual Studio.

The basic mechanism behind scorch is to get a list of items that are in the workspace version and a list of items that have pending changes, comparing that with the list of items on-disk, deleting any item on-disk that is not on the server (or has a pending change).

(You need to union the set of server items with the set of pending changes to avoid deleting pending adds. However, if you want this special cased for a build server and you will never have pending changes, feel free to omit this step.)

You can collect a list of items on the server using Workspace.QueryItems at the workspace version.

Edward Thomson
  • 74,857
  • 14
  • 158
  • 187
  • I think in this case I could probably get away without watching for pending changes, as I simply want to to undo changes that were done on disk (manual remove read only, and modify AssemblyInfo.cs files before build) I am going to accept this answer, because I think it adequately describes the steps required. Thanks for your help! – major-mann Dec 05 '13 at 21:47
1

I just added a Delete Files task to the end of the build process with ** as its parameters. So that way each build should be getting latest from scratch, without having to fuss with the the TFS utilities that may not be properly installed on an agent ahead of time. This solution seemed a lot simpler for me.

Dan Csharpster
  • 2,662
  • 1
  • 26
  • 50