我们如何在Visual Studio构建过程中显示"步骤"?

Max*_*ler 7 build-automation tfs build-process visual-studio

当您从Visual Studio(2008或2005)监视TFS构建时,您可以看到它的位置.

问题是我有一些Post-Build自定义步骤,我希望开发人员能够直接通过UI查看.这些步骤需要一些时间,我们也可以获得构建步骤的"时间".

知道如何显示它吗?

Mar*_*ard 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>
Run Code Online (Sandbox Code Playgroud)

所以最初,我创建了构建步骤并将该步骤的Id保存在名为InstallerStepId的属性中.执行完任务后,我将该步骤的状态设置为Succeeded.如果在该步骤期间发生任何错误,则我将该步骤的状态设置为"失败".

祝好运,

马丁.