The diff tool integrated with Visual Studio has been improving with every version. I still prefer dedicated diff/merge tools for the job, however, and P4Merge is my favorite. This small guide describes how to properly integrate P4Merge with Visual Studio 2015.
Note that this only applies when using TFS. If you use git, Visual Studio will use the diff/merge tools configured with git.
The easiest method of installing P4Merge on your computer is with Chocolatey:
choco install -y p4merge
In order for Visual Studio 2015 to fully integrate with P4Merge, you need to wrap the invocation in two batch scripts:
p4diff.bat
@ECHO OFF
START /WAIT /D "C:\Program Files (x86)\Perforce\" p4merge.exe -dw -nl %6 -nr %7 %1 %2
p4merge.bat
@ECHO OFF
COPY /Y NUL %4
START /WAIT /D "C:\Program Files (x86)\Perforce\" p4merge.exe -dw -nb %8 -nl %6 -nr %7 -nm %9 %3 %1 %2 %4
Save these files somewhere safe, e.g. in the C:\Program Files (x86)\Perforce\
folder.
In Visual Studio, go to Options → Source Control → Visual Studio Team Foundation Server and click the Configure User Tools button. Then add these entries:
Compare
Setting | Value |
---|---|
Extension | .* |
Operation | Compare |
Command | C:\Program Files (x86)\Perforce\p4diff.bat (or where you saved the file) |
Arguments | %1 %2 "0" "0" "0" %6 %7 |
Merge
Setting | Value |
---|---|
Extension | .* |
Operation | Merge |
Command | C:\Program Files (x86)\Perforce\p4merge.bat (or where you saved the file) |
Arguments | %1 %2 %3 %4 "0" %6 %7 %8 %9 |