Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Team Foundation Server - TF Get with changeset number

Tags:

tfs

I'm trying to write a very lightweight "build" script which will basically just get a few files from TF (based on a Changeset number). Then I'll run those files in SQLCMD.

I'm using this:

tf.exe get c:\tfs\  /version:c2681  /force /recursive

However, this appears to get EVERYTHING, not just the files in changeset #2681. I'd like to be able to point it to the root of my tfs workspace, give it a changeset number, and have it just update those few specific files. Also, it appears to be getting older versions (perhaps what was current when changeset #2681 was checked in)?

Is there a way to get just those specific files, WITHOUT needing to call them out specifically in the tf get itemspec?

EDIT: I actually had to add the /force option in order for it to do anything at all. Without force, it doesn't appear to even retrieve from the server a file I deleted locally, that's definitely in the changeset.

thanks, Sylvia

like image 624
Sylvia Avatar asked Apr 02 '12 09:04

Sylvia


People also ask

How do I get a new changeset number in TFS?

If you don't know the number, to find a changeset, In Source Control Explorer, on the menu bar, File => Source Control => Find => Find Changesets. The Find Changesets dialog box will appear. (Optional) Next to the Containing File box, choose Browse.

How do I get a specific changeset in TFS?

Take searching for a changeset in Visual Studio's TFS Source Explorer. Luckily if super easy to do! When you're in the Source Explorer, simply press Ctrl + G and the Find ChangeSet dialog will appear.

How do I link changeset to Workitem to TFS?

Using the TFS Web InterfaceOpen the TFS web interface. Enter the code review id in the Search work items field. Navigate to the Links tab, scroll down to the Changeset control, and click Link to. Enter the changeset id and click OK.


2 Answers

Everything mentioned in Jason's and Richard's posts above is correct but I would like to add one thing that may help you. The TFS team ships a set of useful tools separate from VS known as the "Team Foundation Power Tools". One of the Power Tools is an additional command line utility known as tfpt.exe. tfpt.exe contains a "getcs" command which is equivalent to "get changeset" which seems to be exactly what you are looking for.

If you have VS 2010, then you can download the tools here. If you have an older version, a bing :) search should help you find the correct version of the tools. If you want to read more about the getcs command, check out Buck Hodges's post here.

like image 69
Taylor Lafrinere Avatar answered Oct 11 '22 22:10

Taylor Lafrinere


The TFS server keeps track of what each workspace contains1. Any changes made locally with non-TFS client commands (whether tf.exe, Team Explorer or another client) will lead to differences between the TFS Server's view and what actually exist.

The force options on the various clients just gets everything removing such inconsistencies (effectively resetting both what is on the client and what the server thinks is there).

When you perform a get against a specified version (whether date, changeset or label) you get everything up to and including that point in time, whether on not specifically changed at that point. So getting

tf get /version:D2012-03-30

will get changes made on or before that date.

To get only the items included in a changeset you'll have to do some work yourself, using a command to get a listing of the content of a changeset and parse that to perform the right actions (a changeset can include more than just updates and adds of files2).

It seems to me that if you want to perform a build at each changeset affecting a particular TFS folder you would be better off looking at using TFS Build which is all about doing exactly that – avoid reinventing the wheel – and focus on the build part (other continuous build solutions are available).


1 This will change with TFS11 local workspaces.

2 Eg. handing the rename of a folder will take some non-trivial work.

like image 26
Richard Avatar answered Oct 11 '22 23:10

Richard