VSTS 列出用户参与的项目

VSTS list user's participation in projects

我是公司 VSTS 帐户的管理员。有时,我需要映射用户和项目,即列出特定用户所属的项目。我查看了 VSTS 的许多角落和缝隙并搜索了联机文档,但没有成功。我很感激任何建议。

如果您愿意利用 VSTS REST APIs,您可以:

另一种方式是通过客户端SDK实现。

有针对特定用户获取团队的简单示例,您可以参考:

TfsTeamProjectCollection collection = new TfsTeamProjectCollection(new Uri("[collection url]"));

            collection.EnsureAuthenticated();

           var structureService= collection.GetService<ICommonStructureService>();
            var teamprojects = structureService.ListAllProjects();
            TfsTeamService teamService = collection.GetService<TfsTeamService>();
            UserInfo user = new UserInfo();
            foreach (var tp in teamprojects)
            {

                var teamList = teamService.QueryTeams(tp.Uri);
                foreach(var t in teamList)
                {
                    var userIdentity = t.GetMembers(collection, MembershipQuery.Expanded).Where(ti=>ti.UniqueName.Equals("[user accunt, e.g. domain\test]",StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                    if(userIdentity!=null)
                    {
                        user.Teams.Add(t.Name);
                        user.Alias = userIdentity.UniqueName;
                        user.DisplayName = userIdentity.DisplayName;
                    }
                }
            }
            Console.WriteLine(user);
            Console.Read();