简体   繁体   中英

TFS api how to get default area of project

i am geting project areas in following code but how can i get the default araea of a tfs project

Quick help will be very appreciated

 foreach (Node area in teamProject.AreaRootNodes)
 {
  foreach (Node item in area.ChildNodes)
   {

   }
 }

There's isn't a default area for a project per-se, only an area for a team, a default team is created for your Team Project, so My Team Project will have aa team called My Team Project (or similar) and that will have an default area path.

Then you can do something like this:

TfsTeamProjectCollection collection = GetServer("<server_uri>");
string projectUri = GetProject(collection, "<project_name");

var configSvc = collection.GetService<TeamSettingsConfigurationService>();
var configs = configSvc.GetTeamConfigurationsForUser(new[] { projectUri });

foreach (TeamConfiguration config in configs)
{
    // Output some basic team info.
    Console.WriteLine("Team name: {0}", config.TeamName);
    Console.WriteLine("Team ID: {0}", config.TeamId);
    Console.WriteLine("Is default team: {0}", config.IsDefaultTeam);

    // Access the actual configuration settings.
    TeamSettings ts = config.TeamSettings;

    // Output the information on the teams iterations.
    Console.WriteLine("Product backlog: {0}", ts.BacklogIterationPath);
    Console.WriteLine("Current iteration: {0}", ts.CurrentIterationPath);

    Console.WriteLine("Team iteration paths:");

    foreach (string path in settings.IterationPaths)
        Console.WriteLine("  {0}", path);
}

Taken from Ivan Popek's blog

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM