Can I use WinMerge as my merge/diff tool within Visual Studio? - visual-studio-2010

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?

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!

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 ;)

Related

How can I compare .dsql (Azure SQL DW and PDW) files in Visual Studio 2015?

If I invoke the file diff tool in Visual Studio 2015 on a text file with extension .dsql (Azure SQL DW and PDW SQL script) I get the error:
Error occurred during difference operation: Cannot execute the configured tool
Diff works as expected for other text file extensions.
Visual Studio Professional 14.0.25431.01 Update 3 using VSTS source control.
You can compare text files by using the default file-comparison tool integrated with Visual Studio, the Diff window.
However, you can associate a file type with a third-party compare tool using these configuration steps.
Updated:
Alternatively, you can give a try to WinMerge tool for comparing the files, it's easy and open source:
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 are:
/e /u /wl /wr /dl %6 /dr %7 %1 %2
WinMerge Command Line Options
/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.

Remove Whitespace Before Committing Files to TFS

Visual Studio gives us this great ability to completely customize our work environment, including how we wish to format whitespace. I am very particular about how and where I want tabs, spaces, braces, etc. to appear.
For instance, I prefer tabs to be inserted as tabs not spaces. I also prefer the indentation (Tab size/Indent size) to only be 2 spaces (frankly I don't need 4 spaces to see that the line has been indented).
This is all well and good until I work collaboratively. Everyone else I work with just seem to use the defaults for whitespace/formatting. This causes problems when using source control like TFS. If you compare files worked on by me and then a co-worker, the changes in whitespace also show up. I don't want to see these changes; they're not significant.
Please don't tell me the answer is that the entire team should use the same settings. This isn't the correct answer. That answer is a cop-out for bad design. Why have the ability to customize your environment if everyone is forced to use the same settings?
Why doesn't TFS (or any other source control) remove unnecessary whitespace before committing a file based upon the file type? This has several benefits. One, the storage required to hold the file is less. Two, the transmission of the file to the source control server should be more efficient since the file is smaller (these first two benefits are probably negligible since the files are probably compressed anyway). Three, and most importantly, TFS (or any source control) will no longer report changes in whitespace when doing a file diff.
When I view/edit the file in my environment, it will be reformatted how I've defined it. When someone else views/edits the file, it will be reformatted to their specification.
Is there a way to do this currently in TFS?
Although what you said about is very reasonable, I still want to say the best solution is to get the entire team to use the same standards for white space in code. After all, you are teams.
If you insist on it, below is a workaround that to this problem (only works on your local machine).
In Visual Studio, select Tools / Options / Source Control / Visual Studio Team Foundation System and click the Configure User Tools button.
In the dialog, Add an item with the following settings.
Extension : .*
Operation : Compare
Command : C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\diffmerge.exe
Arguments : %1 %2 %6 %7 %5 /ignorespace
Depending on your Visual Studio version and instalation path (x64/x86), the command option may be...
VS2010: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\diffmerge.exe
VS2012: C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\diffmerge.exe
VS2013: C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\vsDiffMerge.exe
VS2015: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\vsDiffMerge.exe
In the argument option leave it with the same number of arguments as the VS suggests and just add /ignorespace in the end. For example, in the VS2015 it will be:
%1 %2 /ignorespace
More details you can refer this blog: Configure Diff to Show Whitespace
You could also use another alternative. WinMerge is. It also has an option to ignore whitespace (menu Edit -> Options -> Compare -> Ignore all (under the groupbox "Whitespace" at the top)).
How to use WinMerge with TFS you can refer:
Using WinMerge with Team Foundation Server (TFS)
Using WinMerge as the default diff/merge tool in Visual Studio
2012/2013

how to compare two files in visual studio ignoring casing

I want to compare two files in visual studio (files containing stored procs)
So I want to ignore all the "Capital" / "Small" differences in the file.
I opened the command window and used Tools.DiffFiles but its taking the case difference also into consideration
P.S I have already seen this question and answers for it
Although Visual Studio is asked for explicitly, I recommend a different tool: WinMerge.
It indeed has many options for comparing and merging files. It lacks a 3-way-merge though. Of course WinMerge can optionally ignore case.
Visual Studio can be configured so you can call WinMerge using "Tools / External Tools ...". Then you may even install a toolbar item for it. Quite nice!
Most version control systems allow you to use WinMerge as a compare tool. For example for TFS you open the "Tools / Options ..." menu and there you choose "Source Control / Visual Studio Team Foundation Server". Click on the button "Configure User Tools".

How to ignore white space when comparing source in Visual Studio / TFS?

The compare tool in Visual Source Safe (pre TFS) had a handy checkbox to select "Ignore White Space".
Now we are using TFS with Visual Studio 2010, and the compare dialog no longer has this option. (A ridiculous oversight from Microsoft!)
So, is it possible somehow to work around this?
This is a workaround that seems to get around the problem.
In Visual Studio, select Tools / Options / Source Control / Visual Studio Team Foundation System and click the Configure User Tools button.
In the dialog, Add an item with the following settings.
Extension : .*
Operation : Compare
Command : C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\diffmerge.exe
Arguments : %1 %2 %6 %7 %5 /ignorespace
Edit:
Depending on your Visual Studio version and instalation path (x64/x86), the command option may be...
VS2010: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\diffmerge.exe
VS2012: C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\diffmerge.exe
VS2013: C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\vsDiffMerge.exe
VS2015: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\vsDiffMerge.exe
VS2017: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\vsDiffMerge.exe
In the argument option leave it with the same number of arguments as the VS suggests and just add /ignorespace in the end. For example, in the VS2015 it will be:
%1 %2 /ignorespace
There is a "=" button on Visual Studio 2017 toolbar that helps to compare files as you want. Hope this screenshot will help.
The default diff tool in Visual Studio is extremely annoying. I suggest you use an alternative.
WinMerge is my favourite. It also has an option to ignore whitespace (menu Edit -> Options -> Compare -> Ignore all (under the groupbox "Whitespace" at the top)).
See Using WinMerge with TFS.
In VS2015 it's possible to "ignore white space" when comparing clicking a little icon with the = symbol.
Go to "View/Toolbars/Compare Files". In the toolbar click on "Ignore trim whitespace".
Update 2020: we struggled a lot solving conflicts with VS comparison tool and the Tortoise SVN one, so after a research we decided to install Devart Code Compare (free version) which has integration with VS2015/2017/2019, SVN (Tortoise and Ankh), TFS, Mercurial, GIT, etc. and Windows Explorer, so no more nightmares/confusion between different comparisons tools. Give it a try, it's extremely useful. It has also Merge to solve conflicts and Folder diff, which is really useful when SVN does not merge for some reason. Also, clicking on the left/right arrows to copy the changes is a feature that I really like.
Below VS image is from Devart website, but in my case I setup Code Compare to open it outside VS instead of embedded, I think it behaves better. And in VS Options > Source Control > Subversion Environment, I have this:
The default diff tool in VS 2013 does let you ignore whitespace after all. Just run the standard differencing process. When Visual Studio brings up the differences, look on the toolbar, where you will see an icon that looks like a document with 5 dots under it, as shown below. This button toggles whether the displayed differences ignore white space. This worked well enough for me; I wanted it to ignore changes in the white space caused by indentation.
in VS 2012, this might be what you're looking for with no changes to Diff tool.
Opening up the compare screen in VS 2012 and at the top you see the following option in the toolbar. as it might be the same comparison as user: Master screenshot.

Is it possible to use WinMerge inside Visual Studio 2008 and Visual Source Safe 6.0?

I would like to use WinMerge as the default diff tool inside VS2008 from the solutions explorer in place of the "Compare..." context menu item. Is this possible? I'm looking for a quick replacement of the current bland diff tool an I just like WinMerge better. I'm not interested in going to the folder explorer and doing the comparison there.
I'm using Visual Source Safe 6.0 not TFS
Yep, it's possible!
See this link: http://whyiamright.wordpress.com/2008/01/18/changing-the-diffmerge-program-used-by-visual-studio/
Tools-> Options. In the tree, choose Source Control, then the plugin of your choice (VS team Foundation, Source Safe, etc).
Click the "Configure User Tools" button, click add, then specify the appropriate extension, operation, EXE, and arguments list.
This site: has the settings for many, including winmerge: http://blogs.msdn.com/jmanning/articles/535573.aspx
EDIT:
You mentioned VSS: Check out the Winmerge manual here: http://winmerge.org/docs/manual/VersionControl.html. It says how to do it about 1/5th the way down the page.
I think I have this working at a serviceable level if not optimal.
in visual studio go to tools > options > source control > plug-in settings
click the "advanced" button
in the sourcesafe options dialog, switch to the "custom editors" tab
for operation, select file difference
for file extension enter .*
for command line enter
"C:\Program Files\WinMerge\WinMergeU.exe" /x /e /ub /wl /dl %6 /dr %7 %1 %2
click the "add" button then the "ok" button.
using "compare" from a file's context menu or viewing history and selecting "diff" should bring up winmerge with the file comparison. the original is on the left and the modified file is on the right (is that the right placement? should they be swapped?). if you selected a highlighted difference, you can actually sync that area at this time as well. visual studio will just recognize the file has changed and ask you to reload. I haven't gotten to the situation where I'm in an actual "merge" situation so I'm not sure what happens there. I'll update this post if I ever have more info to add.
I'm using VS2008, sourcesafe 2005, and winmerge 2.12.4 installed to the default directory. I copied the settings from this post: http://weblogs.asp.net/garrypilkington/archive/2009/12/16/winmerge-as-a-comparison-tool-in-visual-studio-2008.aspx
I have been wondering about this as well and have not found anything to make it possible in VSS 6.0.
For now, it looks like the answer to our question is "No".
As I stated previously, I don't think we can integrate WinMerge with Visual Studio 2008 and VSS 6.0.
However, I did find that VSS 2005 is backward compatible with VSS 6.0 databases. So, if your server can't change from VSS 6.0, at least perhaps you can change your client to VSS 2005, and then follow the other instructions from the answers here.

Resources