Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MS Office file diff under TFS

When you compare two versions of MS Word doc/Excel book in Team Foundation Server Source Explorer, the result is the boring "Binary filles differ" dialog.

It does not have to be that way though. The relevant apps (Word/Excel) have an excellent built-in diff interface. You can witness it when you work with versioning-enabled SharePoint file library and do compare with a previous version. Also, TortoiseSVN brings it up when you do diffs.

Question - can I enable this in TFS?

like image 686
Seva Alekseyev Avatar asked May 10 '11 20:05

Seva Alekseyev


3 Answers

The best way now I thought is to use MS Word compare which is much better than other doc diff tools (MS word native support compare except merge). By using a powershell script which is provided by (https://github.com/ForNeVeR/ExtDiff), you can trigger the MS word compare function insde TFS compare. In order to solve the PS execution policy issue, you need to alter the content in diff-word.cmd by adding "-ExecutionPolicy Bypass". After introudce the "diff-word.cmd" for .docx compare, it works very well.

like image 98
Jiawei Avatar answered Nov 16 '22 06:11

Jiawei


You can configure comparison (diff) and merge tools per file type (extension). This is available via Tools -> Options -> Source Control -> Visual Studio Team Foundation Server -> Configure User Tools" button or via the command-line with tf diff /configure

In order to set up a comparison tool, you'll specify the extension (use .* if you want it to be used for all files not otherwise specified), the operation you're setting up (Compare or Merge), the command to invoke and the arguments to the command. For arguments, the variables available for use are the following:

%1 = Original file (in diff, the pre-changes file, in merge, the "server" or "theirs" file, the file that is the base file after "their" changes were applied)
%2 = Modified file (in diff, the post-changes file, in merge the "yours" file - the base file with "your" changes applied)
%3 = Base file (in the 3-way merge operation, the file which both "theirs" and "yours" are derived from - the common ancestor.  This doesn't mean it's the version the changes were based from, since this may be a cherry-pick merge)
%4 = Merged file (The output file for the merge operation - the filename that the merge tool should write to)
%5 = Diff options (any additional command-line options you want to pass to your diff tool - this comes into play only when using "tf diff /options" from the command-line)
%6 = Original file label (The label for the %1 file)
%7 = Modified file label (The label for the %2 file)
%8 = Base file label (The label for the %3 file)
%9 = Merged file label (The label for the %4 file)

To use TortoiseSVN -- which seems like it does what you want -- you would specify the command as the file path to TortoiseMerge.exe

For comparisons, specify the arguments: /base:%1 /mine:%2 /basename:%6 /minename:%7

For merges, specify the arguments: /base:%3 /mine:%2 /theirs:%1 /basename:%8 /minename:%7 /theirsname:%6 /merged:%4 /mergedname:%9

This and other information on the arguments for various merge tools (including other word comparison tools like DiffDoc.exe) can be found on James Manning's MSDN blog. You may also find use in another stackoverflow question on invoking the word comparison tool from the command line.

like image 37
iammichael Avatar answered Nov 16 '22 06:11

iammichael


You can also use WinMerge + xdocdiff plugin in TFS, apply these two steps:

  1. Associate WinMerge with VS-TFS: http://manual.winmerge.org/Version_control.html#d0e9669

  2. Enable xdocdiff plugin in WinMerge: http://freemind.s57.xrea.com/xdocdiffPlugin/en/index.html

This way, you will also be able to use all file types that xdocdiff supports.

like image 1
uluorta Avatar answered Nov 16 '22 06:11

uluorta