【问题标题】:Is it possible to use the TFS SDK to create, queue and track builds?是否可以使用 TFS SDK 来创建、排队和跟踪构建?
【发布时间】:2009-03-04 16:57:47
【问题描述】:

我一直在谷歌上搜索,但找不到任何可靠的示例如何做到这一点,或者是否可以做到。我认为它可以。谁能指出我正确的方向?

到目前为止,我一直在查看 msdn 上的 TFS 命名空间文档。我的目标是能够从 Intranet Web 应用程序完全自动化和跟踪我们在 TFS 中的构建。

【问题讨论】:

    标签: tfs sdk build-automation


    【解决方案1】:

    Richard 为我指明了正确的方向,所以我将用我的发现来回答我自己的问题。

    是的,您可以使用 TFS SDK 来创建、排队和跟踪构建。您需要的接口/类位于 Microsoft.TeamFoundation.Build.Client 命名空间中。 IBuildServer、IBuildDefinition 和 IBuildDetail 特别有用。

    TFS 2010 更新:这是一个使用 TFS 2010 SDK 的示例程序,发现 here

    using System;
    using System.Collections.Generic;
    using Microsoft.TeamFoundation.Build.Client;
    using Microsoft.TeamFoundation.Build.Workflow;
    using Microsoft.TeamFoundation.Client;
    
    namespace ManageBuildTemplates
    {
        class Program
        {
            static void Main(string[] args)
            {
                TfsTeamProjectCollection collection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://jpricket-test:8080/tfs/collection0"));
                IBuildServer buildServer = collection.GetService<IBuildServer>();
    
                IBuildDefinition definition = buildServer.GetBuildDefinition("UnitTests", "Definition1");
    
                IBuildRequest request = definition.CreateBuildRequest();
                request.ProcessParameters = UpdateVerbosity(request.ProcessParameters, BuildVerbosity.Diagnostic);
    
                buildServer.QueueBuild(request);
            }
    
            private static string UpdateVerbosity(string processParameters, BuildVerbosity buildVerbosity)
            {
                IDictionary<String, Object> paramValues = WorkflowHelpers.DeserializeProcessParameters(processParameters);
                paramValues[ProcessParameterMetadata.StandardParameterNames.Verbosity] = buildVerbosity;
                return WorkflowHelpers.SerializeProcessParameters(paramValues);
            }
        }
    }
    

    【讨论】:

      【解决方案2】:

      查看 tfsbuild.exe(在 VS 安装的 .../Common9/IDE 文件夹中)。

      这引用了程序集 Microsoft.TeamFoundation.Build.ClientMicrosoft.TeamFoundation.Build.Common,它们看起来很有帮助,...并且包含没有与其他 TFS cient 程序集一起记录的命名空间,但在 MSDN 上 http://msdn.microsoft.com/en-us/library/cc339575.aspx

      【讨论】:

      • 谢谢,这让我找到了解决方案。
      猜你喜欢
      • 1970-01-01
      • 2010-10-16
      • 1970-01-01
      • 2019-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-17
      相关资源
      最近更新 更多