如何在项目之间移动TFS 2010构建定义? [英] How to Move TFS 2010 Build Definition between Projects?

查看:98
本文介绍了如何在项目之间移动TFS 2010构建定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些在ProjectX下创建的TFS 2010构建定义。现在,源代码已移至ProjectY的下一个文件夹。如何将构建定义移至ProjectY,以使其显示在ProjectY的团队资源管理器的构建节点下?

I have some TFS 2010 build definitions that were created under ProjectX. Now the source code has moved to a folder subordinate to ProjectY. How can I move the build definitions to ProjectY so they display under the Builds node of the Team Explorer for ProjectY?

推荐答案

我认为没有现成的东西可以将构建定义从一个项目复制到另一个项目。但是,您应该可以使用TFS API来做到这一点。您将需要将Pete所指的构建过程模板移动到新项目的Build Process Template文件夹中。之后,您将执行以下操作:

I don't think there is something out of the box to copy the build definitions from one project to another. However you should be able to do it using the TFS API. You will want to move the build process templates, which is what Pete is referring to, into the Build Process Template folder for the new project. After that you would do something like:

var server = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("<server uri>"));

IBuildServer buildServer = server.GetService<IBuildServer>();
var buildDetails = buildServer.QueryBuildDefinitions("Project X");
foreach(var build in buildDetails)
{
        var buildDefinition = buildServer.CreateBuildDefinition("Project Y");
        buildDefinition.Name = "Copy of " + build.Name;
        buildDefinition.BuildController = build.BuildController;
        // This finds the template to use
        buildDefinition.Process = buildServer.QueryProcessTemplates("Project Y")[0]; 
        buildDefinition.ProcessParameters = build.ProcessParameters;
        buildDefinition.Save();                
}

有两点需要注意。您将需要处理将工作空间映射从一个项目转换到另一个项目的问题。您还需要更改buildDefinition.Process行以找到特定的模板。

A couple of things to note. You will need deal with converting the workspace mappings from one project to the other. You will also need to change the buildDefinition.Process line to find the specific template.

这篇关于如何在项目之间移动TFS 2010构建定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆