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

Setting Up Additional Configurations and the Files

When creating a new web application project in ASP.NET 4, the web.config is included as expected, but so are two additional files as seen below.


If you don’t see them initially, expand the collapsed entries by clicking on little black arrow to the left of the Web.config filename.

What each file does will be disgusted later on, but first let’s see how to add more files. If you right-click on the web project and go through the menu to add a new item and select Web Configuration File, you will not get a file automatically associated like the Debug and Release files seen above. It will look like the following.


To have things work nicely, the build configurations should be set up first. Go through the toolbar or whatever process you like best to edit the build configurations.


This will provide us with the popup to create new build configurations.


In the next window, fill in the settings that are appropriate for your new configuration. For example, Testing, Staging, etc.


After doing this and reloading the project file, the Web.Testing.config still doesn’t fit into the collapsible Web.config area. This is because it was added before the build configuration, so make sure to add the build configurations first! If you find yourself in this situation, you can manually edit the project file to create the association.

After opening up the project file for editing and searching for Web.config, we find the following.

  <Content Include="Web.config">
  <Content Include="Web.Debug.config">
  <Content Include="Web.Release.config">

Notice the difference for the Debug and Release files? Where is the Testing entry? Searching for it in the project file, it’s found as a normal file entry.

    <Content Include="Web.Testing.config" />

You can manually remove the ItemGroup entry for the Testing file and create a Content entry that mimics the Debug and Release entries.

  <Content Include="Web.config">
  <Content Include="Web.Debug.config">
  <Content Include="Web.Release.config">
  <Content Include="Web.Testing.config">

After saving the changes and reloading the project file, the association for Testing is correct.


Generating the Transformed Configuration Files

At this point, it’s easy to see that the middle portion of the filename corresponds the build configuration. What does it actually do? By default, the deploy will produce a transformed configuration file. This doesn’t happen for normal build operations and debugging, like hitting F5. Take a note here that the Web.Debug.config entry will not be transformed into your debugging web.config file when running in Visual Studio. Without the extension mentioned below, this would only be for deploying the application in debug mode. We will see with an extension that this is possible though. After setting up a Publish entry in One-Click Publish and deploying it to a local file system folder, the following can be seen when Show All Files is selected for the project.


Notice the path objTestingTransformWebConfig and then the original and transformed directories. Comparing the two Web.config entries at this point will show the differences, if any.

Using the Transformation Syntax to Produce Custom Settings per Build Configuration

There are a variety of ways to apply transformation, but the two I find myself using most often are Replace and SetAttributes. Here are some examples:

<?xml version="1.0"?>
<configuration xmlns:xdt="">
      connectionString="Data Source=dbserver;Initial Catalog=dbname;User id=username;Password=password;"

  <appSettings xdt:Transform="Replace">
    <add key="RemoteServerIP" value="" />
    <add key="RemoteServerPath" value="." />

  <connectionStrings xdt:Transform="Replace">
    <add name="MyConnectionString" connectionString="Data Source=dbserver;Initial Catalog=dbname;User id=username;Password=password;" />
    <add name="CsvConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties='text;HDR=Yes;FMT=Delimited';Data Source="/>

The ELMAH connection string and mail settings are using the SetAttributes transform by matching on the name of the attribute. The result of these operations will change the attribute values for connectionString and to, respectively. For the appSettings, the Replace transform type is used to swap out the whole appSettings section. You could handle these in different ways, but I find that usually all or most of the appSettings values change per build configuration type, so I simply replace the whole thing rather than adding transform syntax to each line.

What this provides is a way to set any number of configuration changes based on the build configuration. As shown above, the connection strings don’t have to be worried about and changed when doing different deployments. You can set it and forget it, for the most part.

Please reference MSDN for the full documentation on transformation syntax:

That Works for ASP.NET web.config files, But What About the app.config files?

Unfortunately, it’s not directly built into Visual Studio/MSBUILD, but there is an excellent extension available for free called SlowCheetah – XML Transforms. This extension allows for not only doing these same types of operations on app.config files, but it allows for transformations of the config files during Visual Studio debugging. Bring on F5 integration! It even works for any XML file within your projects. For example, I often have a logging.debug.config and a logging.release.config to keep my web.config or app.config clean. This extension allows for transformations of those files perfectly and outputs them into the bin directory.

It also allows for previewing of the transformations when you right-click on one of the transformation XML files.


The built in functionality is long overdue and a much nicer implementation than using the Enterprise Library dynamic changes feature they added around version 3. There are some other tools available as well, but having it built in reduces the guess work and cross-training. Throw in the SlowCheetah extension and it’s pretty feature complete. Hopefully the Visual Studio team incorporates SlowCheetah’s features in vNext.

Happy Transformations!

I have found that having all projects expanded by default can be annoying, as I tend to open solution files when working in Microsoft Expression Blend.  This often leaves me having to collapse each project individually.  Within Visual Studio, I use PowerCommands for VS2010 and PowerCommands for VS2008 to provide the collapse-all functionality and it works great.

Since Blend 4 uses MEF, I set out on writing an extension to provide this functionality.  I learned how to begin with How to Hack Expression Blend.  The most helpful article I found was Building Extensions for Expression Blend 4 Using MEF by Timmy Kokke.  Following his startup example, I was able to use the debugger and figure out how to interact with Blend’s various parts.  I put forth some effort to have a dropdown menu or button added to the right of the Help entry, but I haven’t finished that exercise yet.  Ideally, I would like to have an entry added to the context menu of the Projects window when right-clicking on a solution or project file.  In the mean time, I have it working with a docking window.

Step 1: Installation

Download (DLL only):

Extract the extension DLL to the folder location “….Program Files (x86)Microsoft ExpressionBlend 4Extensions”.  You may have to right-click on the DLL and click the Unblock button.

Step 2: Using the Extension

After a successful installation, the Window dropdown menu should contain an entry for Collapse All Projects.  As you can see from the screenshot, I have configured the extension to use Ctrl+Shift+C as a shortcut.

Collapse All Projects Menu Entry

Once the menu item is selected, a popup window should appear.  This window is like the Projects, Properties, Assets, etc. windows within Blend, which means you can dock it.  I’ve chosen to dock it to the bottom as shown below.

Collapse All Project Window Docked

Hovering over the window shows the contents.  Simply click the button for the collapse all to be applied.

Collapse All Project Window Expanded

That is it!  If you find any bugs or issues with this, please let me know.  If you get around to making it a context menu item or as a main entry of the top dropdown menu, please share.

Tools Used:

  • Reflector
  • Snoop
  • I wanted to use Mole, but was developing in VS2010.  It doesn’t appear there is a compatible version yet.  Speaking of which, I would really like to see Mole for Silverlight.

Download the Source:

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.