Connecting to TFS2010 with API
If you know TFS 2008 API and try to connect to a tfs 2010 you could probably start with this snippet, but you will get a 404 exception, telling you that the tfs is not available.
|
|
The problem is originated by the new architecture of tfs2010, and the presence of Project collections. Project collections are containers for Team Project, and they are the analogue of a TFS2008 server. The above code cannot work, because you are trying to connect with a TeamFoundationServer object to a tfs that contains a certain number of project collection. To make it work you need to change the server string passed to the constructor in this way
|
|
This works perfectly, because now you can use the TeamFoundationServer object to do whatever you want. If you are curious and you want to enumerate project collections avaliable in a server you can use this piece of code:
|
|
As you can see the TfsConfigurationServer object can be queried with the familiar GetService<T> method asking for a ITeamProjectCollectionService, that has the method GetCollections() to have a list of all Team Project Collection present on the server.
alk.
Tags: Team Foundation Server