Christofer Ohlsson
Christofer Ohlsson

Reputation: 3145

Getting all versions of a specific file in TFS?

Given a Team Foundation Server repository, how can I retrieve all checked in versions (or versions later than a specific changeset) of a specific file?

The reason I'm asking is I want to track what versions contain a certain string. So I thought I'd download them all and then grep or similar.

Upvotes: 1

Views: 406

Answers (1)

jessehouwing
jessehouwing

Reputation: 114461

There is no standard way to do it from the UI or the commandline, but it's easy to do from the Client Object Model.

You can use the VersionControlServer.DownloadFile method and supply a versionspec. And you can use the VersionControlServer.QueryHistory method to query all the different changeset versions of the file.

Combined you'd be able to piece together a small Console application or a Powershell script to grab all versions. And grep them at the same time by adding a bit of Regex :).

Check out this blog post to see how to connect to TFS and get hold of the ProjectCollection from which you can request the VersionControlServer object.

Upvotes: 4

Related Questions