I need to compare two files in my project, which is written in C#. Can I integrate WinMerge (or any other diff tool) with Visual Studio and use it easily from within?
-
2Do you want to configure the diff tool for Visual Studio, or do you want to integrate a diff tool in your application? The former is [answered here](http://stackoverflow.com/questions/4466238/how-to-configure-visual-studio-to-use-beyond-compare), the latter is too broad. – CodeCaster Jan 09 '15 at 11:12
-
http://comparisontools.codeplex.com/ – Claies Jan 09 '15 at 11:13
-
This question is unclear. You want to integrate it into Visual Studio or your own program? What exactly do you mean by "integrate"? Do you need the tool to open up *inside* Visual Studio or your application, or *be opened by* one of those two? Please clarify the exact needs you have. – Lasse V. Karlsen Jan 09 '15 at 11:16
-
Hey sorry for late reply I need to compare two files in my app without calling any third party exe.I want only see the differences like winmerge shows two panes. – Neeraj Dubey Jan 09 '15 at 11:18
-
What are you *really* trying to do? If you don't want to use another program, what does "integrate" mean? Are you asking whether VS2010 has a built-in comparison functionality? Are you asking whether there is an add-in that only works inside VS2010? That *would* be another tool, just not with an `exe` extension. – Panagiotis Kanavos Jan 09 '15 at 12:16
-
I am very sorry for not explaining my need,In one liner i have to compare two files in my windows application,where i have to option to select file one the select file 2 and compare. – Neeraj Dubey Jan 09 '15 at 12:21
-
Originally, the question had been about something completely different. I edited it to be clear and reflect what the (accepted!) answer answers. – Palec Dec 07 '15 at 14:42
2 Answers
There is a more detailed answer on paulbouwer.com life and technology Replace diff/merge tool in Visual Studio Team System with WinMerge article, having also what arguments you need to pass.
I will reproduce it wholly, because I could not explain it better than him:
Replace diff/merge tool in Visual Studio Team System with WinMerge
JANUARY 31, 2010
I have been using Visual Studio Team System 2008 for a while now and am really starting to like the tightly integrated source control and work item functionality. One thing I cannot get used to is the basic diff/merge tool.
Where is the detail ?
The screenshot below demonstrates the basic nature of the diff tool built into Visual Studio Team System. There is no indication of the number of differences between the files being diff’ed or even the actual differences on a particular line …
WinMerge
There is an alternative and it is both open source and free ! From the WinMerge site:
WinMerge is an Open Source differencing and merging tool for Windows. WinMerge can compare both folders and files, presenting differences in a visual text format that is easy to understand and handle.
Download WinMerge and install it.
Configure Visual Studio
Open Source Control > Visual Studio Team Foundation under the Tools > Options menu in Visual Studio.
Click on Configure User Tools … and the Configure User Tools dialog will become available.
Add the WinMerge details for the Compare Tool. Click on the Add … button on the Configure User Tools dialog and configure as per the screenshot below. The arrow button next to the arguments text box exposes details about the information that Visual Studio can provide the tool being configured.
The configured arguments below are:
/e /u /wl /wr /dl %6 /dr %7 %1 %2
Add the WinMerge details for the Merge Tool. Click on the Add … button on the Configure User Tools dialog and configure as per the screenshot below. The arrow button next to the arguments text box exposes details about the information that Visual Studio can provide the tool being configured.
The configured arguments below are:
/e /u /wl /dl %6 /dr %7 %1 %2 %4
The Compare and Merge Operations should now be configured to use WinMerge.
WinMerge Command Line Options
WinMerge contains a number of command line options. The following are the ones used in the configuration above.
/e Enables WinMerge to be closed with a single Esc key press.
/u Prevents WinMerge from adding either the left or right hand side file path to the Most Recently Used (MRU) list.
/wl Opens left hand side as read-only.
/wr Opens right hand side as read-only.
/dl Description for left hand side title bar.
/dr Description for right hand side title bar.
Finally a decent diff !
Now a Compare in Visual Studio is more meaningful, It shows the number of differences, their positions within the compared files and actual differences per line. WinMerge supports custom syntax colouring and diff colouring.
PERSONAL NOTE:
I tested it, and I couldn't make changes go to to my local file, so I followed the Youen's advice on that page of removing the /wr
parameter for Compare operation and now it works nice!

- 4,122
- 4
- 47
- 81
-
2If you want to be able to edit the file while comparing, then use these arguments: `/e /u /dl %6 /dr %7 %1 %2` – Akira Yamamoto Jul 05 '17 at 01:53
-
-
1Of course I didn't. I recommend you to move it closer to the compare arguments. – Akira Yamamoto Jul 05 '17 at 23:30
-
@AkiraYamamoto: I didn't move it there because of maintaining my transcription ipsis verbis exactly equal the original source. – sergiol Jul 05 '17 at 23:33
I use WinMerge for comparing files and I integrated winmerge with visual studio. for this follow this instruction :
- in visual studio select : Tools > Options
- from this dialog select : Source Control > Visual Studio Team Foundation Server
here you must select Configure User Tools and then select Add. after that, from opened dialog box enter .* in Extension field and set Operation to Compare and into Command field enter WinMerge executable path and select OK.
that's all ;)

- 499
- 5
- 24