Command Line `diff` for Windows

March 18, 2014

msbuild.exe /t:Rebuild MySolution.sln

The output of the above command on my legacy app was about 2200 lines. I was trying to figure out why those 2200 lines ended in ‘Build Successful’ on my workstation and ‘Build Failed’ on our new CI box. On *nix, I would reach for diff, which quickly shows the differences between two files. On Windows, I reached for PowerShell.

The first step is getting the output into a text file. With PowerShell, this is super easy.

msbuild.exe /t:Rebuild MySolution.sln | Out-File c:\temp\local-build.txt

I ran this once on each machine and ended up with a local-build.txt and ci-build.txt to compare.

Compare-Object $(Get-Content .\local-build.txt) $(Get-Content .\ci-build.txt) | Out-File 'c:\temp\compare-build.txt'

Now I had a file with just the differences between the two files.


Profile picture

Written by @sghill, who works on build, automated change, and continuous integration systems.