One usually has the need to compare two files or two folders, or two branches, especially as a frequent user of Visual Studio, one hopes to find a way to use Visual Studio to complete the comparison job in Visual Studio with somewhat the way like Source Control or Version Control software for comparison.
This article will cover this topic and related issues (we use the current version of 2019 16.11.0).
It seems this article is a little bit too long, I split it into two: one with native Visual Studio Tool, another is Visual Studio with Extension or Non-Visual Studio.
After splitting the article into two, they are still too long, I split it as three,
- Compare Files (1), with TFS and Git GUI in Visual Studio
- Compare Files (2), with Visual Studio Built-in Tool --- this article
- Compare Files (3), with Visual Studio Extension or Other Apps
Introduction
Contents of this article series,
- Compare Files (1), with TFS and Git GUI in Visual Studio
- TFS
- Git
- Compare Files (2), with Visual Studio Built-in Tool
- Command-line in Visual Studio
- Visual Studio Developer Command Prompt
- Windows Prompt
- Compare Files (3), with Visual Studio Extension or Non-Visual Studio Apps
- A: Tools outside of Visual Studio for Files Comparison
- Online comparison, such like diff
- Other Applications, such like VS Code or Word
- B: Visual Studio Extention for Comparison Tools from Third Parties:
- Code Compare in Visual Studio --- devart.com
- Compare Files VS2019 --- marketplace.visualstudio.com
- A: Tools outside of Visual Studio for Files Comparison
The Visual Studio only supports GUI Compare Files feature to TFS or Git, the source control tools. We will discuss these features in the first article of this article series; and then as an alternative, we invoke the Visual Studio built-in Comparison Tools from command line that we will discuss in the second article in this article series, and finally, we discuss the alternative ways to compare files without Visual Studio in the third article.
Compare Files (2), with Visual Studio Built-in Tool
1, Command-Line in Visual Studio
To display the Command window within Visual Studio, choose View => Other Windows => Command Window.

Using the command,
Tools.DiffFiles FileName1 FileName2
can do the diff job, like this,

It can also auto-complete paths to the files - making it easier to have the right, you type in the file name, the IntelliSense (auto-completion) will show all files with the name within Visual Studio solution, such like,

It can also compare files that are not within Visual Studio by full file path, while different from the files within Solution, you have to type the full path of the file name, you will get IntelliSense from your path like this,

2, Visual Studio Developer Command Prompt
Notice, that Visual Studio 2019 includes two command-line shells for developers,
-
Visual Studio Developer Command Prompt
A standard command prompt with certain environment variables is set to make using command-line developer tools easier. Available since Visual Studio 2015. -
Visual Studio Developer PowerShell
More powerful than a command prompt. For example, you can pass the output of one command (known as a cmdlet) to another cmdlet. This shell has the same environment variables set as Developer Command Prompt. Available since Visual Studio 2019.
To open Developer Command Prompt or Developer PowerShell from within Visual Studio,

Starting in Visual Studio 2019 version 16.5, Visual Studio includes an integrated terminal that can host either of these shells (Developer Command Prompt and Developer PowerShell). You can also open multiple tabs of each shell. The Visual Studio terminal is built on top of Windows Terminal. To open the terminal in Visual Studio, choose View > Terminal.













Join the conversation! Your thoughts help the community grow.