public void IncludeAllAreas()
        {
            try
            {
                TfsTeamProjectCollection tpc = TfsConnect();

                ICommonStructureService4 css = tpc.GetService <ICommonStructureService4>();
                ProjectInfo project          = css.GetProjectFromName(TeamProject);
                TeamSettingsConfigurationService teamConfigService = tpc.GetService <TeamSettingsConfigurationService>();
                var teamConfigs = teamConfigService.GetTeamConfigurationsForUser(new string[] { project.Uri });
                foreach (TeamConfiguration teamConfig in teamConfigs)
                {
                    if (teamConfig.IsDefaultTeam)
                    {
                        TeamSettings settings = teamConfig.TeamSettings;
                        foreach (TeamFieldValue tfv in settings.TeamFieldValues)
                        {
                            tfv.IncludeChildren = true;
                            teamConfigService.SetTeamSettings(teamConfig.TeamId, settings);
                        }
                    }
                }
                Console.WriteLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
                throw;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Create TFS Team if not exists
        /// </summary>
        /// <returns></returns>
        public TeamFoundationTeam CreateTeam()
        {
            // Check team already exists
            var teams        = _tfsTeamService.QueryTeams(_projectInfo.Uri.ToString());
            var existingTeam = teams.FirstOrDefault(t => t.Name == _softwareProjectName);

            if (existingTeam != null)
            {
                Console.WriteLine($"Team '{existingTeam.Name}' already exists.");
                return(existingTeam);
            }

            //Create TFS Team
            TeamFoundationTeam team = _tfsTeamService.CreateTeam(
                _projectInfo.Uri.ToString(), _softwareProjectName, _softwareProjectDescription, null);

            //Set the IterationPaths and BacklogIterationPath for the TFS Team
            var teamConfiguration     = _teamSettingsConfigurationService.GetTeamConfigurations(new[] { team.Identity.TeamFoundationId });
            TeamConfiguration tconfig = teamConfiguration.FirstOrDefault();
            TeamSettings      ts      = tconfig.TeamSettings;

            ts.IterationPaths       = new string[] { $"{_projectInfo.Name}\\{_softwareProjectName}\\Sprint 1" };
            ts.BacklogIterationPath = $"{_projectInfo.Name}\\{_softwareProjectName}";
            TeamFieldValue tfv = new TeamFieldValue();

            tfv.IncludeChildren = true;
            tfv.Value           = ts.BacklogIterationPath;
            ts.TeamFieldValues  = new TeamFieldValue[] { tfv };
            _teamSettingsConfigurationService.SetTeamSettings(tconfig.TeamId, ts);

            Console.WriteLine($"Team '{team.Name}' created.");

            return(team);
        }
        public void SetPlanningIterations()
        {
            TfsTeamProjectCollection tpc = TfsConnect();
            ICommonStructureService4 css = tpc.GetService <ICommonStructureService4>();
            ProjectInfo project          = css.GetProjectFromName(TeamProject);
            TeamSettingsConfigurationService teamConfigService = tpc.GetService <TeamSettingsConfigurationService>();
            var teamConfigs = teamConfigService.GetTeamConfigurationsForUser(new string[] { project.Uri });

            foreach (TeamConfiguration teamConfig in teamConfigs)
            {
                if (teamConfig.IsDefaultTeam)
                {
                    TeamSettings settings = teamConfig.TeamSettings;
                    settings.IterationPaths = PlanningSprints.ToArray();
                    teamConfigService.SetTeamSettings(teamConfig.TeamId, settings);
                    Console.Write(new string('.', PlanningSprints.Count));
                }
            }
            Console.WriteLine(string.Format(" ({0} iterations)", PlanningSprints.Count));
        }