Note: There is a newer version of this article, click here to view.

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.


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:


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:


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.
The results will look like this:

With FinalBuilder Task
Note: These screenshots are for FinalBuilder 4. FinalBuilder 5 is identical, but you don't need the FBVersion attribute any more, and you can use .fbz5/.fbp5 for the project file extension.

<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"           
          ShowBanner="false" />

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 in: FinalBuilder

Post Rating


# Raoul
Friday, August 18, 2006 5:17 AM
Cool. Thanks Angus.

Friday, August 17, 2007 4:34 PM
Great article.
I have another question.
Can you run a TFSBuild.proj team build project from within Finalbuilder?
# angus
Monday, August 20, 2007 2:06 AM
Hi Lou,

I replied to your query on the forums, which can be accessed at the following URL:

Tuesday, December 18, 2007 3:55 PM
We're using Visual Studio 2008 now. Do you have a new version of FinalBuilder.MSBuild.Tasks.dll for 2008 available?
# angus
Tuesday, December 18, 2007 6:55 PM
Hi Lou,

The approach outlined above should work with Visual Studio 2008 (we tested it here and it worked fine.)

If you experience problems, please drop me an email - angus at finalbuilder dot com.

There are some big improvements in the pipeline in the Team Build department, so watch this space. :).


# class-a
Monday, March 17, 2008 7:42 AM
I have FB5 ( and the FinalBuilder.MSBuild.Tasks.dll has in itself that it's version 4... :(

If you create the 4.0 folder under \HKEY_LOCAL_MACHINE\SOFTWARE\VSoft\FinalBuilder\4.0\ and add a new string "Location" with the value "C:\Program Files\FinalBuilder 5\FinalBuilder5.exe" in it, it'll work. (Assuming that's where you've installed FinalBuilder.exe)

It'd be nicer though if you could update the MSBuild Tasks for version 5 though :)
# angus
Monday, March 17, 2008 5:02 PM
Hi Dennis,

- If you use the "FBVersion" attribute in the FBCmd task then the task will try to find that version of FinalBuilder to run the project.

- If you omit the "FBVersion" entirely then the task will autodetect the version from the project file name.

Hopefully that solves your problem. :-).
Tuesday, February 17, 2009 3:46 PM
Very nice. But when I can't seem to get is for each individual task in the FB project to write it's results to the Team Build that's calling the FB Project. (steps like Copy File, Create Archive, etc).

Is there a way to ensure the output of the FB Project is logged entirely to the TF Build (and not just the "Ran TFCmd, result was success")?

Is there a way to explicity log (even to the FB log) values (sort of like a debug ... Received BuildId Var of %BuildID% from Team Build) would be helpful.
Wednesday, July 20, 2011 1:41 PM
Is there a way to get output variables from fbcmd

PropertyName="BuildWorked" />

Post Comment

Only registered users may post comments.