TFS Equivalent of SVN Export

Here is a little trick to download the latest version of a source control folder from TFS. The idea is to use the Web Access API to retrieve the data.
Basically, you will get a Zip containing the HEAD version of the specified source control folder.

Here is the URL you have to use :


http://tfs-server:port/tfs/Collection/TeamProject/Team/_api/_versioncontrol/itemContentZipped?repositoryId=&path=url-encoded-source-control-path

The yellow parameters are mandatory, the green ones can be omitted.
Replace the parameters as described:
  • tfs-server is the TFS server hostname
  • port is the TFS port (usually 8080)
  • Collection is the name of your team project collection
  • TeamProject is the name of your team project
  • Team is the name of the team
  • url-encoded-source-control-path is the URL encoded source control path (for example, $/Project1/Main/Sources/Folder/SubFolder becomes %24%2FProject1%2FMain%2FSources%2FFolder%2FSubFolder
The main benefit of this URL is that it allows you to retrieve a source control folder without having to create workspaces and mappings (and thus avoiding the manual deletion of the associated $tf folders).

This URL is using Windows Authentication, so if you are using CURL (for example) on a non-Microsoft platform, you have to pass the --ntlm switch together with your windows credentials to retrieve the Zip package.

Comments

Post a Comment

Popular posts from this blog

Create a draft release and start it using the TFS REST API

Adding a delay before processing Textbox events

Change the deployment URL of a ClickOnce application