Friday, October 12, 2007

Fixing odd diff results when using Visual Studio .NET 2005 Compare on files with line feeds

The Compare tool that ships with Visual Studio .NET 2005 is called DiffMerge.exe and it's located under "C:\Program Files\Microsoft Visual Studio 8\Common7\IDE" by default. The posting on MSDN says the default "Option" passed in on the tool is only /ignorespace.

This causes a problem with our hybrid Windows/Unix users (i.e. users who edit files on Unix, then FTP them over to their Windows box to check them in to TFS) as files with line feeds were not diffing correctly. Oddly the line above the line that was different would show a difference, even though they were exactly the same. The line that was different (right below the line showing the difference) did not show a difference.

To fix this we had to change the DiffMerge Option to /ignoreeol. These values override the default values (described in the link above). Here are our steps.

1) In VS.NET 2005 go to Tools > Options > Source Control > Visual Studio Team Foundation Server
2) Click on Configure User Tools > Add
3) Fill in the Following

- Extension = *
- Operation = Compare
- Command = C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\diffmerge.exe
- Arguments = %1 %2 /ignoreeol

4) Ok > Ok > Ok
5) Tree down to file $/MyteamProject/MyApp/.../myaffectedfile > Right Click > View History
6) Highlight the last two versions > Right Click > Compare.

For us, the files now diff correctly.

No comments: