Visual Studio Diff



You can invoke devenv.exe /diff list1.txt list2.txt from the VS Developer Command Prompt or, if a Visual Studio instance is already running, you can type Tools.DiffFiles in the Command window, with a handy file name completion.

Visual studio difference between build and rebuildVisual studio diff ignore whitespace
  • When you double-click a Commit, Visual Studio opens its details in a separate tool window. From here you can revert the commit, reset the commit, amend the commit message, or create a tag on the commit. When you click a changed file in the commit, Visual Studio opens the.
  • Compares two files. The differences are displayed in a special Visual Studio window. Syntax devenv /Diff SourceFile TargetFile SourceDisplayName TargetDisplayName Arguments. The full path and name of the first file to be compared. The full path and name of the second file to be compared.

A little-known feature of Visual Studio is that it can be used as a two-way diff tool. The diff tool can be invoked from the command line, which means that it can be easily integrated into most source control clients. Using VS as your diff tool allows you to remain in the IDE while diffing your changes against source control. You can make changes to your local file with the benefit of intellisense and ReSharper (if you have it) while the diff updates in real-time.

Visual Studio Diff Two Files

To invoke Visual Studio’s diff tool from the command line, call devenv.exe (the VS executable) with the “/diff” switch. Devnenv.exe is located in %VS110COMNTOOLS%/../IDE, typically “C:Program Files (x86)Microsoft Visual Studio 11.0Common7IDE”. This is the path for Visual Studio 2012 (version 11), but the basic pattern holds for other versions — each VS install creates an environment variable to the “common tools” directory which can be used to locate the “IDE” directory. Also note that if you are using Visual Studio Express, you will not find “devenv.exe” — the executable will be called something like “WDExpress.exe”.

When using the /diff switch, you must pass two arguments — the paths to the two files to diff. The first will appear on the left in the IDE, the second on the right. You can optionally pass two additional arguments, which VS will use as the “name” of the left and right files. These optional parameters are useful when integrating with source control, where the files may have odd temporary paths — names such as “SOURCE” and “TARGET” or “THEIRS” and “MINE” could be appropriate. The full command line, assuming %1 and %2 are the two files to be diffed, looks something like this:

'%VS110COMNTOOLS%/../IDE/devenv.exe' /diff %1 %2 NAME1 NAME2

Visual Studio File Diff

Provide this command to your source control client (using the appropriate named parameters for the files to be diffed — these will vary by source control system), and you’ll be diffing without leaving the IDE in no time.