Programmatically add new iteration in TFS

回眸只為那壹抹淺笑 提交于 2019-12-01 17:53:52
taylonr

Does this tutorial solve your problem? http://blogs.microsoft.co.il/blogs/shair/archive/2009/01/30/tfs-api-part-10-add-area-iteration-programmatically.aspx

Google-Fu "tfs api add iteration"

From glancing at his code, (and using TFS) it looks like iterations are getting treated as hierarchies. That's why you see things like "Release1\Sprint2" etc... you can have them nested deep... deep down they're probably just a path and that's why he's using the add path etc

After some experimentation based on taylonr's link, here's what I came up with as a minimal solution for adding an iteration, in case any one else runs into this:

    public void AddIteration(string projectName, string iterationName)
    {
        using (var tfsCollection = new TfsTeamProjectCollection(new Uri(tfsServerUrl), getTfsCredentials()))
        {
            tfsCollection.Authenticate();
            var css = tfsCollection.GetService<ICommonStructureService>();
            string rootNodePath = string.Format("\\{0}\\Iteration", projectName);
            var pathRoot = css.GetNodeFromPath(rootNodePath);
            css.CreateNode(iterationName, pathRoot.Uri);
        }
    }
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!