For a long time I’ve been using WinMerge as diff tool for Visual Studio. Unfortunately it doesn’t do 3-way merging, which still forces me to use the merge tool supplied with Visual Studio. I set out to find a solution to change that because, let’s face it, the merge tool in VS is not the best on the market. Enter: P4Merge.
P4Merge is a free diff/merge tool that does support 3-way merging and also looks quite good.
Using P4Merge as a diff tool
Setting up P4Merge as your comparison tool is quite easy. Go to Tools –> Options and open Source Control. Make sure “Visual Studio Team Foundation Server” is selected as you current source control plug-in. Go to the Visual Studio Team Foundation Server tab and click the Configure User Tools button.
Then click on Add and set the options as shown below:
Hit OK and you’re done. NOTE: You may have to supply a different path to P4Merge if you have installed it in a different location.
Using P4Merge as a merge tool
Merging with P4Merge and TFS is a little tricky because P4Merge expects the output file for the merge operation to exist before you actually do the merge. VS does not create that file before calling the tool, but expects the tool to create it instead.
With a simple batch file we can work around this problem. The contents of this file should be:
@ECHO OFF
COPY /Y NUL %4
START /WAIT /D "C:\Program Files\Perforce" p4merge.exe %3 %1 %2 %4
Once you’ve created this file, go through the same steps as above for Compare, but this time select the Merge operation and point to the batch file instead of the P4Merge program. The end result should be something like this:
NOTE: For the sake of sharing across multiple users on my machine, I’ve placed the batch file in C:\Tools.
Once this is done, get out of the options and try it out. Enjoy!
Kudos to Richard Banks for posting this originally. I made some changes the batchfile to make implementing it easier for new users.




