7

当您从 Visual Studio(2008 或 2005)监视 TFS 构建时,您可以看到它在哪里。

问题是我有一些构建后自定义步骤,我希望开发人员能够直接通过 UI 看到。这些步骤需要一些时间,我们还可以获得构建步骤的“时间”。

知道如何显示它吗?

4

2 回答 2

9

这是我通常用于在 TFS 2008 中向构建报告添加步骤的模式。(请参阅http://code.msdn.microsoft.com/buildwallboard/了解我通常在 Team Build 会谈中使用的完整示例)

基本上,神奇的是在 TFS2008 中为您提供了一个名为“BuildStep”的自定义任务。这是我生成和 MSI 安装程序并在报告中构建适当构建步骤的部分:

  <Target Name="PackageBinaries">

    <!-- create the build step -->
    <BuildStep TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
               BuildUri="$(BuildUri)"
               Message="Creating Installer"
               Condition=" '$(IsDesktopBuild)' != 'true' " >
      <Output TaskParameter="Id"
              PropertyName="InstallerStepId" />
    </BuildStep>

    <!-- Create the MSI file using WiX -->
    <MSBuild Projects="$(SolutionRoot)\SetupProject\wallboard.wixproj"
  Properties="BinariesSource=$(OutDir);PublishDir=$(BinariesRoot);Configuration=%(ConfigurationToBuild.FlavourToBuild)" >
    </MSBuild>

    <!-- If we sucessfully built the installer, tell TFS -->
    <BuildStep TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
               BuildUri="$(BuildUri)"
               Id="$(InstallerStepId)"
               Status="Succeeded"
               Condition=" '$(IsDesktopBuild)' != 'true' " />

    <!-- Note that the condition above means that we do not talk to TFS when doing a Desktop Build -->

    <!-- If we error during this step, then tell TFS we failed-->
    <OnError   ExecuteTargets="MarkInstallerFailed" />
  </Target>

  <Target Name="MarkInstallerFailed">
    <!-- Called by the PackageBinaries method if creating the installer fails -->
    <BuildStep TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
               BuildUri="$(BuildUri)"
               Id="$(InstallerStepId)"
               Status="Failed"
               Condition=" '$(IsDesktopBuild)' != 'true' " />
  </Target>

因此,最初,我创建了构建步骤并将步骤的 ID 保存在名为 InstallerStepId 的属性中。完成任务后,我将该步骤的状态设置为成功。如果在该步骤期间发生任何错误,那么我将该步骤的状态设置为“失败”。

祝你好运,

马丁。

于 2008-10-22T18:42:20.317 回答
0

请注意,在@Martin Woodward 的出色示例中,PackageBinaries 是现有的TFS 构建目标之一。如果您想使用自己的目标,可以使用CallTarget任务从已知目标之一调用它们,例如,

<Target Name="AfterDropBuild">
    <CallTarget Targets="CreateDelivery"/>
    <CallTarget Targets="CreateInventory"/>
</Target>

然后在您的目标(例如,CreateDelivery)中按照 Martin 的示例使用 BuildStep 任务。

于 2011-12-08T17:31:17.043 回答