【问题标题】:How can we display a "step" inside Visual Studio build process?我们如何在 Visual Studio 构建过程中显示“步骤”?
【发布时间】:2010-09-18 14:37:45
【问题描述】:

当您从 Visual Studio(2008 或 2005)监控 TFS 构建时,您可以看到它的进度。

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

知道如何显示它吗?

【问题讨论】:

    标签: visual-studio tfs build-process build-automation


    【解决方案1】:

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

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

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

    【讨论】:

      【解决方案2】:

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

      基本上,神奇的是在 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 的属性中。完成任务后,我将该步骤的状态设置为成功。如果在该步骤中出现任何错误,那么我将该步骤的状态设置为“失败”。

      祝你好运,

      马丁。

      【讨论】:

        猜你喜欢
        • 2017-02-01
        • 2016-12-14
        • 1970-01-01
        • 1970-01-01
        • 2017-07-30
        • 1970-01-01
        • 1970-01-01
        • 2012-09-24
        • 2017-01-14
        相关资源
        最近更新 更多