How can I query a folder in TFS to show me the latest ChangeSet for each object?
Currently, our DBAs require the TFS changeset number for any scripts/stored procedures/functions that need to get deployed. I have a folder in our TFS project with all of my stored procedures in it, and I'd like to run a single query that will list each object in that folder and the latest changeset. I'开发者_C百科m using VS2010 Team Explorer with TFS Server 2008 (I believe), and would be happy to script it in PowerShell or some other tool, but don't know where to begin. Can someone provide me some direction?
TFS has a lot of extensibility points that make running a query like this possible. If it were me, I'd simply use the tf.exe
command-line client. For example:
tf properties $/Path/To/Folder -recursive
This will show you the latest changeset for each of the files beneath the given folder (as well as other information.)
While the output from the command-line client is well-formed and easily parseable, you may still prefer a more programmatic way to do it. You can use the very powerful .NET API in order to query from the server. You'll want to call the VersionControlServer.GetItems
method. For example:
ItemSet items = vcs.GetItems(@"$/Path/To/Folder", RecursionType.Full);
If you haven't yet, you should take a look at the TFS 2008 Power Tools, which include the TFS Power Shell Extensions. My powershell-fu is weak, but I think that the above in Power Shell works out to be something like:
$tfs = get-tfs http://yourserver:8080/tfs/YourCollection
$tfs.VCS.GetItems('$/Path/To/Folder', $tfs.RecursionType::Full)
精彩评论