Try again

200512270453934121.gif

博客园 首页 联系 管理
FinalBuilder comes with a built-in MSBuild Task, and Team Foundation Build uses MSBuild for its internal workings. So it's only a short step to being able to use FinalBuilder as a build engine inside Team Foundation Build.

If you're new to Team System or Team Foundation Build, you may find MSDN's Team Foundation Overview useful.

Prerequisites

The latest release of FinalBuilder contains some enhancements to the MSBuild Task, so you should upgrade if you are using a version earlier than FinalBuilder 4.2 (August 18, 2006.) Download page.


Step One: Install FinalBuilder on the Team Build Machine

Both FinalBuilder and the Team Foundation Build Service will need to be installed on the same machine. For information on installing the Team Foundation Build Service, see MSDN's HowTo: Set Up a Build Computer.


Step Two: Create a new Team Build Type

Tip: From this step onwards, you can use Visual Studio 2005 on any workstation with access to the Team Project that you wish to build.

Working inside Visual Studio's Team Explorer, right click on Team Builds and choose "New Team Build Type."

New Build Type

Step through the wizard to choose the Team Build server name, a working directory for the build, and any solutions you wish to build.

You need to add at least one Solution to the new Team Build Type, even if you don't want to build that solution with Team Build (we'll remove it later.) When you complete the wizard, close the XML project file which appears.

Alternatively, you can skip this step and add the FinalBuilder engine to an existing Team Build Type.


Step Three: Check out and edit the Team Build Type project file

Double-click "Source Control" in Team Explorer and navigate to the TeamBuildTypes folder, then to the folder for the build type that you wish to edit. You may need to use Get Latest Version in order to have a copy of the Team Build folder on your local machine.

Right click the TFSBuild.proj file, and choose "Check out for edit." Then double-click the file to open it in Visual Studio.

Check Out The Build Project


The default Team Build project definition file (TFSBuild.proj) looks like this:

Build Type Definition


Step Four: Remove unnecessary content

The default Team Build Type definition file contains a lot of boilerplate material that you may not need.

Hint: If you still want to build some Visual Studio solutions using Team Build (rather than FinalBuilder) then you may wish to leave this content and just add the FinalBuilder task to the bottom (if this is the case, skip to the next step.)

If you only want to use FinalBuilder to build solutions, scroll down until you see the first ItemGroup tag:

ItemGroups-Before

Now delete everything from this tag down to the </Project> tag at the end of the file.

When you're done, the bottom of the definition file should look like this:

ItemGroups-After

If you were to save this Team Build Type Definition file as shown above, check the file in, and then run it, then the build would run successfully but no compilation would occur.


Step Five: Add FinalBuilder Task(s)

Copy and Paste the following XML into the Team Build project definition file, after the </PropertyGroup> tag.
<UsingTask TaskName="FinalBuilder.FBCmd"
           AssemblyFile="C:\Program Files\FinalBuilder 4\FinalBuilder.MSBuild.Tasks.dll"/>
<Target Name="BeforeCompile">
   <FBCmd ProjectFile="$(SolutionRoot)\TeamBuildTypes\FinalBuilder Build\fbmsbuildtest.fbz4"           
          AllowInteractive="false"
          DontWriteToLog="false"
          StopIfFBFails="true"
          ShowBanner="false" 
          FBVersion="4" />
</Target>


The results will look like this:

With FinalBuilder Task

Tip: You don't need to specify all of the attributes shown, only the ProjectFile attribute. The attributes shown are the default values.


Step Six: Set the FinalBuilder Project Path

In the example shown, the ProjectFile path is set to $(SolutionRoot)\TeamBuildTypes\FinalBuilder Build\fbmsbuildtest.fbz4. You will need to set this path to the location of  the FinalBuilder project on the Team Build Server.

ProjectFile Highlighted

$(SolutionRoot) evaluates to the build directory on the server, where the Team Project's files are extracted before building.

Hint: Whenever a Team Build is run, the entire contents of the Team Project's Source Control Repository is fetched to the $(SolutionRoot) directory before building, so you can use this path for any file which is located inside the Team Project's repository.

Step Seven: Change the Assembly Path

The AssemblyFile attribute of the UsingTask tag will need to be changed to point to the installation directory of FinalBuilder on the Team Build server:

AssemblyFile Tag

Hint: If you don't know the assembly file path (or it is different between build servers), then you can install the FinalBuilder.MSBuild.Task.dll file into the Global Assembly Cache (GAC) and change the AssemblyFile attribute to a fully qualified AssemblyName.

Step Eight: Check in and Run!

Close the project file, select Check In Pending Changes, and then build the Team Build Type. You should see the build run successfully, and the output from FinalBuilder will be available in the Team Build log.

Run the Team Build

Tip: If the Team Build doesn't run properly, make sure the TFSBuild.proj file is checked in!

Team Build Status:
8 - Build Completed.jpg

The Team Build Log, showing FinalBuilder output:
9 - Log Extract.jpg


You're done!


Advanced: Running Multiple FinalBuilder Projects as Part of the Team Build

In the example above, we had FinalBuilder run as part of the "Compile" Build Step, under the BeforeCompile target. There is also an AfterCompile target. If you have specified any solutions to build as part of Team Build, then they are built between these two targets.

You can include multiple <FbCmd> tasks inside a single <Target> tag. You can also have multiple <Target> tags for different targets. For example, you could use the AfterGet target to set up source files, the BeforeTest/AfterTest targets to run tests, and  the BeforeDropBuild/AfterDropBuild targets to deploy built files.

Here is an example using different FinalBuilder projects to build sources, run tests, and deploy built files:

Multiple Targets


For a full list of available targets, see this list on MSDN.

Note: No matter how many <FbCmd> and <Target> tags you use, you only need to include the <UsingTasks> tag once.


Advanced: Passing Team Build & MSBuild Properties to FinalBuilder

Team Build defines a number of specialist MSBuild properties (like SolutionRoot.) You can pass these to your FinalBuilder project using the "Variables" attribute:

Setting Variables

Use the syntax "VariableName=VariableValue". Separate multiple variables with semicolons.

In the example above, the project "Compile.fbz4" would need to contain FinalBuilder variables named SolutionRoot and TeamProjectName.
posted on 2007-07-27 14:50  共同学习,共同进步  阅读(912)  评论(1编辑  收藏  举报