Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the current iteration path from TFS

Tags:

c#

.net

tfs

tfs-sdk

I'm trying to get the current iteration path for the teams TFS project. The way I'm trying to do this is by using the blog from http://blog.johnsworkshop.net/tfs11-api-reading-the-team-configuration-iterations-and-areas/ . I start by getting the team configurations from the following code:

        TfsTeamProjectCollection tpc = TFSConncetion(@"http://tfs/url");
        var configSvc = tpc.GetService<TeamSettingsConfigurationService>();
        var configs = configSvc.GetTeamConfigurationsForUser(projectUri);

The problem with this is that my configs is always null, even though I'm a member of the team. I'm positive my projects URI is correct as well. After this I would get the team settings and use that to display the current iteration path.

TeamSettings ts = config.TeamSettings;
Console.WriteLine(ts.CurrentIterationPath);

Even if this didn't work I can still query the iteration dates from the team setting to get the one iteration that has a start date before today and finish date after today. The main problem is that I can't get my TeamSettingsConfigurationService to return anything but null when I try to get the team configurations with my projects URI.

like image 395
user2748943 Avatar asked Sep 27 '22 08:09

user2748943


1 Answers

There must be something wrong with your server connection or the project uri you're passing as the other code looks okay.

Maybe try something like this:

TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri("http://server:8080/tfs/collection"),
                          new System.Net.NetworkCredential(tfsUserName, tfsPassword));
tpc.EnsureAuthenticated();

Connect to Team Foundation Server from a Console Application

There is a good sample here which you can download (WPF client) and it will allow you to select a server connection, Team Project and Team:

TFS API Part 46 (VS11) – Team Settings

You can step through it and check the values you're passing into your code.

The sample gets the team configuration information is the same way you have in your code.

TeamSettingsConfigurationService teamConfig = tfs.GetService<TeamSettingsConfigurationService>();
    var configs = teamConfig.GetTeamConfigurationsForUser(new[] { projectInfo.Uri });

Once you have the collection of TeamConfiguration items then you need TeamSettings.CurrentIterationPath

like image 103
rerwinX Avatar answered Oct 13 '22 00:10

rerwinX