Pham X. Bach
Pham X. Bach

Reputation: 5432

TFS - Get latest version of multiple files

Could someone help me: How to get latest version of multiple files in TFS?

I'm starting to try automating the publishing of a project that is often changing, start with this problem.

So let's say that I have a list of 10 changed files in TFS that is not in the same changeset, and I need some tool/add-in/script that can get latest version of all those 10 files in one click/enter.

Anyway to do that, or any suggestion for me to start searching? Thanks for any help!

Upvotes: 0

Views: 422

Answers (2)

Tore Østergaard
Tore Østergaard

Reputation: 4602

You can call the tf.exe command like this:

tf get file1.cs
tf get file2.cs
...

And then do that for every file. If they are all in the same folder you can just specify the folder and all files will be refreshed. You can also specify their common ancestor and add the /recursive option:

tf get ancestorFolder /recursive

Here is the full reference for the tfs get command.

Upvotes: 1

The Shooter
The Shooter

Reputation: 733

Assuming that you know which files you need, the below script can help.

tf get "tfs path to file/folder" /force /recurse

use /force when you need to overwrite existing file. use /recurse when you want to get all files within a folder.

you can run this inside dos for loop command. Something like:

FOR /F ["options"] %%variable IN (<file name containing list of files>) DO tf get "%%variable" /force /recurse

You would need to study ["options"] as it's difficult over here to explain everything.

Alternatively you can use same logic inside powershell but there you would need to load tfs assemblies and run the required commands but will give you more flexibility and control with what you want to do. Get Latest Version of Folder from TFS, using Powershell How to get latest version of specific project in TFS using Powershell.

Upvotes: 1

Related Questions