2008-10-22 50 views

回答

9

这是我通常用于添加在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> 

所以一开始,我创建构建步骤,并保存在一个名为InstallerStepId属性格式步骤的ID。在完成我的任务后,我将该步骤的状态设置为成功。如果在该步骤中发生任何错误,那么我将该步骤的状态设置为失败。

祝你好运,

马丁。

+0

那就是EXACLTY吧!谢谢!!!! – 2008-10-22 18:48:15

0

请注意,在@Martin Woodward的伟大示例中,PackageBinaries是现有的TFS build targets之一。如果你想用你自己的目标,你可以使用CallTarget任务,从已知的目标之一,如给他们打电话,

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

然后在你的目标(例如,CreateDelivery)使用BuildStep任务按马丁的例。

相关问题