到目前为止,我可以通过编程方式创建一个新的团队和一个新的区域,但是当我导航到TFS 2015“工作”选项卡时,我看到了这个错误:
TF400509:未指定积压迭代路径。您必须选择迭代路径。
因此,如果我手动选择一次迭代,那么我得到:
TF400512:您尚未为团队选择任何区域。您必须先选择至少一个区域,然后才能使用产品待办事项,任务板或磁贴等功能。
这是我的代码:
tpc.Authenticate();
// Create New Area
ICommonStructureService css = tpc.GetService<ICommonStructureService>();
string rootNodePath = string.Format("\\Onboarding\\Area");
var pathRoot = css.GetNodeFromPath(rootNodePath);
var newAreaPath = css.CreateNode("Area 51", pathRoot.Uri);
// Create new Team with Same Name
TfsTeamService tts = tpc.GetService<TfsTeamService>();
string newteamname = "Area 51";
string teamdescription = "Area 51 Team Description";
IDictionary<string, object> prop = new Dictionary<string, object>
{
{"Area", "Area 51"},
{"Iteration", "\\Onboarding\\Iteration\\Onboarding" }
};
tts.CreateTeam(onboardingProject.Uri.ToString(), newteamname, teamdescription, prop);
TfsTeamService teamService = tpc.GetService<TfsTeamService>();
ProjectInfo projectInfo = css.GetProjectFromName("Onboarding");
var allTeams = teamService.QueryTeams(projectInfo.Uri);
那么问题又来了吗?
您可以在什么时候为新区域设置 Backlog Iteration ,以及如何/在何处为新团队选择新区域
答案 0 :(得分:1)
您可以添加以下代码来设置积压迭代路径:
TeamSettingsConfigurationService tscs = tpc.GetService<TeamSettingsConfigurationService>();
IEnumerable<TeamFoundationTeam> teams = tts.QueryTeams(projectInfo.Uri);
TeamFoundationTeam team = teams.Where(a => a.Name == "Area 51").FirstOrDefault();
var teamconfigs = tscs.GetTeamConfigurations(new[] { team.Identity.TeamFoundationId });
TeamConfiguration tconfig = teamconfigs.FirstOrDefault();
Console.WriteLine(tconfig.TeamName);
TeamSettings ts = tconfig.TeamSettings;
ts.IterationPaths = new string[] { string.Format("\\Onboarding\\Iteration 1") };
ts.BacklogIterationPath = string.Format("\\Onboarding\\Iteration 1");
TeamFieldValue tfv = new TeamFieldValue();
tfv.IncludeChildren = true;
tfv.Value = projectInfo.Name + "\\Area 51";
ts.TeamFieldValues = new TeamFieldValue[] { tfv};
tscs.SetTeamSettings(tconfig.TeamId,ts);
答案 1 :(得分:0)
您要找的是TeamSettings Class,您可以查看如何以编程方式设置TeamSettings的案例TFS 2012 API Set TeamSettings Programmatically:
// Set up default team sprint date and time
var teamConfig = _tfs.GetService<TeamSettingsConfigurationService>();
var css = _tfs.GetService<ICommonStructureService4>();
string rootNodePath = string.Format("\\{0}\\Iteration\\Release 1\\Sprint 1", _selectedTeamProject.Name);
var pathRoot = css.GetNodeFromPath(rootNodePath);
css.SetIterationDates(pathRoot.Uri, DateTime.Now.AddDays(-5), DateTime.Now.AddDays(7));
var configs = teamConfig.GetTeamConfigurationsForUser(new[] { _selectedTeamProject.Uri });
var team = configs.Where(c => c.TeamName == "Demo").FirstOrDefault();
var ts = team.TeamSettings;
ts.BacklogIterationPath = string.Format(@"{0}\Release 1", _selectedTeamProject.Name);
ts.IterationPaths = new string[] { string.Format(@"{0}\Release 1\Sprint 1", _selectedTeamProject.Name), string.Format(@"{0}\Release 1\Sprint 2", _selectedTeamProject.Name) };
var tfv = new TeamFieldValue();
tfv.IncludeChildren = true;
tfv.Value = _selectedTeamProject.Name;
ts.TeamFieldValues = new []{tfv};
teamConfig.SetTeamSettings(team.TeamId, ts);
有用的博客:http://blogs.microsoft.co.il/shair/2012/05/23/tfs-api-part-46-vs11-team-settings/