Although the default compare tool built in with Visual Studio/TFS is adequate, I find situations where third party solutions have automatically resolved situations that the default tool did not. I have used a variety of tools and prefer KDiff3, but WinMerge, Beyond Compare, and others are all great options.

After setting up Visual Studio to use a custom tool, it will automatically use it for both comparisons and merges without prompting you. The automatic calculation of conflicts on check-ins is still done on TFS. This means it may list a certain number of conflicts, but when you open them locally with your custom tool they may all be resolved automatically. It may seem like it’s an extra step, but if you were just using the built-in tool, you would have handle all of the conflicts.

Go to Tools -> Options from the main menu.

Then go to Source Control -> Visual Studio Team Foundation Server.

From here click on Configure User Tools button, which will bring up the following popup.

After clicking Add, you will be given the opportunity to provide information for using a custom merge and compare tool.

You can see from the drop down there are two choices that correspond to our tools. Third party tools use different command line arguments for specifying compare and merge operations, so we need to specify them separately.

  • For the extension textbox, enter “.*” without the quotes. This will use the tool you specify for all of the file types.
  • Select the operation for Compare or Merge.
  • In the Command textbox, click the ellipse button and find the executable to the third party utility you have installed.

You can see the right arrow is clicked in the figure above and it expands a help menu. This menu is specifying how Visual Studio will provide the files, options and information to the utility.

For this example I’m using KDiff3. The arguments I use for compare are:

    %1 –fname %6 %2  –fname %7

For the merge arguments, I use:

    %3 –fname %8 %2  –fname %7 %1 –fname %6 -o %4

Tools Used:

  • KDiff3 0.9.95
  • Visual Studio 2010 SP1
Merge Sign
Merge? No Problem!

By default, a Team Foundation Server (TFS) Team Project will have multiple check-out enabled. This means that the same file can be checked-out by more than one individual at the same time. This is actually a good thing in that blocking changes does not occur when different people need to access a file and one or more people are unavailable to undo their check-out.

Some people then get concerned with merge complications (a.k.a. merge hell). At the surface, merging may seem complex, but when broken down it should be fairly straightforward. The built in tool with Visual Studio for compare/merge and third party tools, like KDiff3 and WinMerge, all provide a great way to automatically detect changes in a file. Most of the time those changes are not on the same line and the merge is automatically handled. In the case where two or more people are changing the same line, method or functional piece of code, I would consider that it really isn’t a problem with merging. The team members need to find out why two people are working on the same thing.

Sometimes it may be that two different people recognized the same bug and fixed it. They may both see convoluted code and refactor it to be cleaner. In these types of situations the second person checking in that then sees a merge conflict should be able to easily identify what happened and either throw away their changes or overwrite the previous check-in. In the strictest sense, one could argue that the developer should open a bug and add it to the backlog, but the case of refactoring smelly code doesn’t really fit that model. Often times I will see sprints with a refactoring bucket and task, which means tracking this type of change isn’t easily predictable. Either way, these aren’t major areas of merge complications.

There are times where merging is not that simple, but I would argue that it’s usually a project management issue or an architectural issue at that point. Two people shouldn’t be actively developing the same feature, because that would mean there is a communication breakdown. In an agile environment, the team members should be communicating at least once a day and be aware of what others are working on completing. If the file in question contains so much code that multiple people are inadvertently effecting each other, the code may need to be refactored on a larger scale to remove tight coupling. It should follow a separation of concerns approach.


I find allowing multiple check outs to be more beneficial than not. When Alice forgets to undo a check-out before she leaves for the day and Bob needs to update some other portion of the file, he inevitably ends up with a couple choices that all reduce his productiveness. He can move on to something else, forcing a context-switch in which he’ll have to return to when the file is available. He could find an administrator and have Alice’s check-out undone, which would leave Alice to handle a merge situation anyway with her local changes and whatever Bob checks in. Worst of all, Bob could have no other work to do and he ends up doing nothing productive.

In order build a solution using WCF RIA Services on a build server, a little tweak may be needed to the configuration depending on how your solution has evolved.

Using an example of a Silverlight client project and a server side web application using WCF RIA Services, we quickly identify the problem.  Whenever a change is made to the WCF RIA Services project, Visual Studio will update the Silverlight project and development continues.  On the build machine this isn’t the case, as Visual Studio isn’t used to initiate the build.  This means that the Silverlight project would fail to build.

Even though there is no need to specify the build order when using Visual Studio, the problem with WCF RIA Services on a build server goes away if the Silverlight project is forced to build after the WCF RIA Services project.

Right-click on the solution and select Project Dependencies. 

Solution Context Menu

The following window should appear.  Verify that the Silverlight project has a dependency on the WCF RIA Services project.

 Project Dependencies Window


A Visual Studio 2008 edition that supports Team Foundation Server.

Creating a Build Agent:

Start out by opening the Team Explorer window, which can be done by navigating through the menu View –> Team Explorer.  A list of solutions may appear, but if not, click on the icon highlighted in the image below and select the Team Portal project as appropriate.

Team Explorer Builds

Expand the Builds folder that is one level deep within the Team Portal project.  Upon right clicking on the Builds folder, the following menu will be displayed.  The starting point is Build Agents, so click on Manage Build Agents.

Right Click on Builds Folder

A new window will appear that allows the creation of new and editing of existing build agents.

Manage Build Agents Window

After clicking New, a popup window displays asking for the properties and configuration to create the new build agent.  The default values are shown below.

  1. Fill out a display name for the build agent.  This build agent can be used with multiple build definitions, as will be shown below.
  2. Enter the name of the build server.
  3. Optionally change working directory to be used on the build server.  Using a shared location on the build server can be useful for team members to troubleshoot.

Build Agent Properties

After clicking okay, the newly created build agent should appear in the create and edit screen.

Manage Build Agents Part 2

Creating a Build Definition:

Now that a build agent is created, a build definition needs to be created and associated with the build agent.  In Team Explorer, under the Team Portal directory, right click the builds directory again and click on New Build Definition.

New Build Definition Context Menu

The initial screen shown below is what should be shown, which will allow for entering all of the required information for a build definition.

Build Definition Creation

Enter a verbose name for the build definition.  For the continuous integration build definitions, appending something like “_CI” may be helpful.  If you would like multiple branches to be built separately using continuous integration, appending something like “_Trunk_CI” may be helpful.

Build Definition Name

On the next tab, one or more Source Control Folders may be set up.  The only need for multiple would be in the case that solutions reference other solutions within the TFS structure.  If branching is used, be sure to narrow down the Source Control Folder to the appropriate level.  It may be useful to have all branches handled through a single build definition, but I prefer to have them individually set up.

If you actually select the text within the Source Control Folder, an ellipsis button will appear allowing you to select the appropriate location through a select folder popup.

Build Definition Source Control Folder

On the project file tab, you will see something similar to the following.  It should automatically populate the version control folder using the information previously provided, but it will warn about needing to actually create the file.  Click the create button, which will add the folder TeamBuildTypes at the root level of Team Portal and create the necessary MSBuild files.  Note that these files and folders are added to source control.  The next few screen shots will walk through the creation process for the MSBuild project.

Build Definition Project File

If the Source Control Folder you entered contains more than one solution file, you will see a list of all available solutions to build.  Select all that you want to build as part of this build definition.

MSBuild Project File Solutions

Under the configurations tab, select all of the target configuration you want to build during this build definition.  For example, Release, Debug, Staging, etc. and any Platform combinations that may be appropriate.

MSBuild Project Configurations

Within the Options tab, you can set up which automated tests are to be executed and if code analysis should be run.  Note that in order for these to run on the build server, Visual Studio must be installed, as the MSTest framework and Code Analysis settings are not part of TFS.

MSBuild Project Options

After clicking Finish, we are brought back to the build definition window and the warning should be replaced with the message “Found MSBuild project file”.

Build Definition Version Control Folder

In the source control explorer window, you should now see newly created MSBuild folder directory beneath the top level Team Portal folder.

Source Control Explorer TeamBuildTypes

A list of files within the directory show that the wizard created two files.  The *.rsp is not in a human readable format, but the *.proj file is the MSBuild XML file that may be of interest for customization at a later point.

Detailed TeamBuildTypes

The next tab in the build definition creation is for setting up how long each type of build result should be kept.  By kept, it means storing the full source, test results, code analysis and anything other that may be part of the build process.  The only real concern here is disk space on the build server.  Remember that if you have many solutions using continuous integration on the build server this may become an issue.  It may take an extra step or two, but since the code is always stored in TFS, you can rebuild from any point in history.

Build Definition Retentions

The next tab is how the build definition and previously created build agent are tied together.  Select the build agent from the drop down menu.  The new button will allow you to create a build agent as part of the build definition creation process, but for the sake of this post, I’ve separated the two.  The text entry area is asking for the place to copy the output from the build process.  Generally, I leave it on the build server, but any network location will work.  If you refer back to the folder location I used for the build definition’s working folder, you can see I’ve created a share on the build server called “builds”.  Within the builds directory are two sub-directories, “completed” and “working”.  The working folder is where each build agent executes the assigned build definitions.  The completed folder is where the output from the build definition is copied.  Within each of the sub-directories, I have folders that match the build definition.  The output created from the build definition automatically is contained in a generated folder name that includes a timestamp, so there is no worry of things getting overwritten.

Build Definition Defaults

The last tab in creating a build definition is to specify how the build will be triggered.  You can have it as a manual process, after each check-in or accumulated check-ins, or even specify specific recurrence patterns like a nightly build.

Build Definitions Triggers

Managing Alerts:

From the Team drop down menu, select Project Alerts.

Manage Alerts Team DropDown

The following window will then allow selecting which types of alerts you would like to receive.  By default, the email address and HTML format are already populated.

Project Alerts

For full control over the alerts, go to the Team drop down menu and select Alerts Editor.

Alerts Editor Context Menu

The following tabbed window will open and allow for full customization and creation of alerts.  As shown, you can create combinations using AND and OR criteria in the alerts definition.

Alerts Editor

Testing the new Build Definition and Build Agent:

Going back to the Team Explorer window and within the Team Portal –> Builds directory, right click on the newly created build definition.  Then click Queue New Build.

Queue Build Context Menu

The Queue Build window should appear.  No changes should be required.  Just click “Queue”.

Queue Build Window

After clicking “Queue”, the Build Explorer tabbed window should be open.  This window allows for filtering by build definition, status and agent.

  • Red ‘X’ = Failed
  • White circle with a Green Arrow = In Progress
  • Three white overlapping squares = Queued
  • Green Check = Success

The Build Explorer window has two tabs that can be navigated to at the bottom.  Once builds are finished, the are automatically removed from the Queued tab and moved to the Completed tab.

Build Explorer

By double-clicking on the build line entry, the details will be opened in a new tabbed window.  From here, access to the log can be found through the linked file located in the targeted drop location.  The full BuildLog.txt can be quite large.

Build Details

The Release.txt is usually much smaller and can be found by expanded the Result details and clicking the Release.txt link.

Build Details Part 2 build_34


A lot of customization can be applied to the build process.  I’ve found the following book very helpful.

Book: Inside the Microsoft Build Engine: Using MSBuild and Team Foundation Build (PRO-Developer) Inside the Microsoft Build Engine: Using MSBuild and Team Foundation Build (PRO-Developer)

If you’re wondering why your Visual Studio may have less options than in some of my screen shots, it may be because I have the Visual Studio Team System 2008 Team Foundation Server Power Tools – October 2008 Release installed.  That install is not required for the purpose of this post.


Microsoft© Team Foundation Server 2008 install bits.

The Process:

Upon starting the setup process, the following screen is shown with a list of options.  For the build server, select Team Foundation Build and click Install.

TFS Install Wizard Start

The next screen is Microsoft asking to record and report any issue with the install experience.  Pick your preference and click Next.

TFS Install Wizard Feedback

Of course, thoroughly read the EULA and if you accept, check the box and click Next.

TFS Install Wizard EULA

Next up is the System Health Check.  If you don’t meet any of the prerequisites, follow the instructions provided.

TFS Install Wizard Progress

The default folder is shown below (on Windows 7 64-bit).

TFS Install Wizard Destination Folder

The Visual Studio Team Foundation Build service will run as a typical Windows Service, which can be found through Control Panel –> Administrative Tools –> Services.  As noted in the screen shot, this should not be a user account.  Create an account specifically for Team Foundation Build and set your password policies as appropriate.  Remember, if the password expires on the account, the service Logon property will need to be updated.  If the account’s password is invalid, all builds will fail.

TFS Install Wizard Service Account

A confirmation screen will show before proceeding.

TFS Install Wizard Summary

After the typical progress bar screen and upon successful installation, the following will be shown.  Be sure to check for any updates and install them as appropriate.

TFS Install Wizard Completion

By going to Control Panel –> Administrative Tools –> Services, the newly installed Visual Studio Team Foundation Build service can be seen.  The default values after install are shown, which have the service start automatically.

Windows Services

This service operates using HTTP, which means it’s dependent on the HTTP service.

Windows Service Dependencies

If your build server will be working with solutions created using the .NET v4 Framework, the following adjustments need to be made.  This also requires installing the .NET v4 Framework on the build server.  Within the file C:Program Files (x86)Microsoft Visual Studio 9.0Common7IDEPrivateAssembliestfsbuildservice.exe.config, adjust the following setting.

MSBuildPath XML Entry


Remember to keep the build server clean.  The definition of clean should be that only the absolutely required software be installed.  Third party tools should be included in the solution, if possible.  One of the goals of continuous integration is to allow a new team member to join, get latest from source control and start working.  The build server gets a fresh copy from source control every time a build is done to help simulate this process.  I would imagine most people are familiar with the phrase “But it works on my machine” and keeping the build server clean is a great step toward eliminating that issue.

What should be installed then?  Typically, Visual Studio if you’re going to take advantage of Automated Unit Testing and Code Analysis.  Things like the Silverlight tools may be required too, depending on your application.

Useful Links: