Diffs and Merges–Better Tools for TFS

One of the most frequent tasks that developers face is ‘comparing’ (diff between) two versions of a source file.  Another related task is that of merging two (or more versions of) files. The built-in comparer/merger in Visual Studio is extremely limited in this regard. There are two tools (Beyond Compare and WinMerge) out there that I have used and would recommend over the built-in comparison viewer.

Beyond Compare (free for 30 day trial only, then approximately $50 for a user license)

To configure the diff and merge to work with this tool, follow the instructions here. A quick recap of configuring it for use with TFS is given below: 

Configuring Beyond Compare as the Diff tool in TFS

  1. In Visual Studio Choose Options from the Tools menu.
  2. Expand Source Control in the treeview.
  3. Click Visual Studio Team Foundation Server in the treeview.
  4. Click the Configure User Tools button.
  5. Click the Add button.
  6. Enter “.*” in the Extension edit.
  7. Choose Compare in the Operation combobox.
  8. Enter the path to BComp.exe in the Command edit.
  9. In the Arguments edit, use:
    %1 %2 /title1=%6 /title2=%7

Configuring Beyond Compare as the 3-way Merge tool (v3 Pro)

  1. Follow steps 1-6 above.
  2. Choose Merge in the Operation combobox.
  3. Enter the path to BComp.exe in the Command edit.
  4. In the Arguments edit, use:
    %1 %2 %3 %4 /title1=%6 /title2=%7 /title3=%8 /title4=%9

Configuring Beyond Compare as the 2-way Merge tool (v3 Std, v2)

  1. Use the same steps as the 3-way merge above, but use the command line:
    %1 %2 /savetarget=%4 /title1=%6 /title2=%7

Winmerge (free, non-expiring version available)

In Visual Studio do the following:

  • Click on Tools menu
  • Click on Options menu item
  • Expand Source Control tree item
  • Select Visual Studio Team Foundation Server tree item
  • Click on Configure User Tools… button

Configuring WinMerge for Comparisons (Diffs)

To use WinMerge as the Compare/Diff tool:

  • Click the Add… button
  • For Extension, type *
  • For Operation, select Compare
  • For Command, browse for C:\Program Files\WinMerge\WinMerge.exe
  • For Arguments, type /x /e /ub /wl /dl %6 /dr %7 %1 %2
  • Click OK to accept

Configuring WinMerge for Merging

To use WinMerge as the Merge tool:

  • Click the Add… button
  • For Extension, type *
  • For Operation, select Merge
  • For Command, browse for C:\Program Files\WinMerge\WinMerge.exe
  • For Arguments, type /x /e /ub /wl /dl %6 /dr %7 %1 %2 %4
  • Click OK to accept

Summary

The built in diff and merge tools in TFS (and VSS) are extremely limited. To get around these limitations, use either WinMerge (free) or Beyond Compare (free for 30 days only) – and configure these in Visual Studio as described in this post.

Cloud Advisory Services | Security Advisory Services | Data Science Advisory and Research

Specializing in high volume web and cloud application architecture, Anuj Varma’s customer base includes Fortune 100 companies (dell.com, British Petroleum, Schlumberger).

All content on this site is original and owned by AdverSite Web Holdings, Inc. – the parent company of anujvarma.com. No part of it may be reproduced without EXPLICIT consent from the owner of the content.

Anuj Varma – who has written posts on Anuj Varma, Technology Architect.


Leave a Reply

Your email address will not be published. Required fields are marked *