Team Foundation Server - TF Get with Change Kit Number

I am trying to write a very lightweight β€œbuild” script that basically just gets a few files from TF (based on the change set number). Then I ran these files in SQLCMD.

I use this:

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

However, this seems to get EVERYTHING, not just the files in change set # 2681. I would like to point it to the root of the tfs workspace, give it the change set number and just update these few specific files. Also, he seems to be getting older versions (perhaps what was relevant when change set # 2681 was changed)?

Is there a way to get only these specific files WITHOUT having to call them specifically in tf get itemspec?

EDIT: I really needed to add the / force option so that it doesn't do anything at all. Without power, it does not seem to even retrieve a file from the server that I deleted locally, which is definitely in the changeset.

thanks Sylvia

+6
source share
3 answers

The TFS server monitors that each workspace contains 1 . Any changes made locally using client commands other than TFS (be it tf.exe , Team Explorer, or another client) will result in differences between the TFS server view and what actually exists.

Power parameters for different clients simply get everything, eliminating such inconsistencies (effectively dropping both what is on the client and what the server thinks).

When you make a call against a specified version (whether it is a date, a set of changes or a label), you get everything before and including this point in time, regardless of whether they have changed at the moment. Therefore getting

 tf get /version:D2012-03-30 

will receive changes made before or before this date.

To get only the items included in the change set, you will need to do some work yourself, using the command to get a list of the contents of the change set and analyze what to do the right thing (the change set may include more than just updating and adding files 2 ).

It seems to me that if you want to build in each set of changes that affect a specific TFS folder, you'd better look at using TFS Build, in which everything is done this way - avoid reinventing the wheel - and focus on (other continuous build solutions are available )


1 This will change with TFS11 local workspaces.

2 For example. passing a folder rename will require some non-trivial work.

+2
source

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

If you have VS 2010, you can download the tools here . If you have an older version installed, a bing :) search will help you find the right version of the tools. If you want to learn more about the getcs command, see the Buck Hodges post here .

+4
source

The team will receive all sources for this change set. By default, it will receive files that, in its opinion, differ between your workspace and the server. However, using the / force option, you ask him to get everything, regardless of the state in which he thinks your workspace is (which is much slower, but has the advantage that your workspace is fully synchronized with the server).

Thus, just removal / strength is likely to achieve what you want.

edit As I said above, tfs will receive all files that, in its opinion, are different from the server. If you manually delete the file from your local workspace, TFS will not know that it is not in your local version, so it will not think that it needs to update the file. There are three options for this:

  • Use / force to make sure everything is in sync, and put up with it very slowly.
  • Do not modify files in the workspace using anything other than the TFS tools (tf.exe, Visual Studio, the TFS tool for the Explorer shell). You should not just delete files on your local hard drive - if you really need to delete them, then delete them in the original control.
  • Go offline in TFS before making changes manually. Then, when you go online, TFS will look for all the changes you have made and add them to your pending changes so that TFS will know about them.
+1
source

Source: https://habr.com/ru/post/912213/


All Articles