2008-10-22 48 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任務按馬丁的例。

相關問題