Visual Studio overall is a brilliant tool for building software. However, it’s not without its niggles. Although the default diff tool is OK, it’s far from excellent, so I tend to opt for WinMerge.
This was going to be a post detailing how much I hated having to add all the seperate file extensions in the Configure User Tools dialog, and how you could work around this by generating a huge csv list of all the file extensions in your source tree using the following code:
let join sep (col:string seq) = String.Join(sep, col)
Directory.GetFiles(@"F:\_src\dev\", "*.*", SearchOption.AllDirectories)
|> Seq.map (fun f -> Path.GetExtension(f).ToLower())
|> join ","
However, in classic fashion, just before this post was to be published, a colleague who’d configured WinMerge as his default compare tool complained to me about the default merge tool. I asked him to open the appropriate dialog, and saw there a single file extension:
This is a moment I’m sure many of us have had. Probably a moment like the time you had that huge string concatenation method reviewed by a colleague, and their response was:
Why didn’t you use String.Join?
The only saving grace in this instance was the fact that my colleague hadn’t seen the blog post (I’m not even sure he’s aware that I have a blog), so I didn’t look half the idiot that I felt like. So, this post has quickly devolved into a quick example of how to set up WinMerge as your default compare tool, as well as a semi-permanent reminder of how much I can suck.
The option to configure diff tools is found in Tools -> Options -> Source Control -> Visual Studio Team Foundation Server -> Configure User Tools…
Simply fill in the dialog using the following settings:
That’s the WinMergeU.exe file in WinMerge’s install directory for the command, .* for the extension, and the following for the arguments:
- /e – because I like to close things with escape.
- /x – so WinMerge just closes if the files are the same.
- /maximize – so that WinMerge always opens maximized.
- /wl – so the left file is read only.
- /wr – so the right file is read only.
%1 and %2 are simply the files to compare. Easy, and not half as annoying as I at first thought.