Compare two files in Visual Studio

2019-01-07 01:16发布

I saw new comparsion tool in VS 2012 for comparing two files or two versions of file. I like it. But when I tried to find it I can't because I don't use TFS. Is there a way how can I just compare two files with builtin feature in VS but without TFS?

16条回答
Summer. ? 凉城
2楼-- · 2019-01-07 01:40

If you have VS installed, you could also call

"%VS110COMNTOOLS%..\IDE\vsdiffmerge.exe" "File1" "File2"

or for VS 2013

"%VS120COMNTOOLS%..\IDE\vsdiffmerge.exe" "File1" "File2"

Source: http://roadtoalm.com/2013/10/22/use-visual-studio-as-your-diff-and-merging-tool-for-local-files/

查看更多
老娘就宠你
3楼-- · 2019-01-07 01:40

For VS 2017 Install https://marketplace.visualstudio.com/items?itemName=vs-publisher-457497.FileComparer2017

The problem is that you can't compare files in diferent proyects, but you can copy the files in the same project to compare...

Context Menu

File Diference

查看更多
爱情/是我丢掉的垃圾
4楼-- · 2019-01-07 01:40

I believe this to be one of the better extension for Visual Studio 2012, it's called Code Compare and can be found here.

查看更多
唯我独甜
5楼-- · 2019-01-07 01:43

I have always been a fan of WinMerge which is an open source project. You can plug it into Visual Studio fairly easily.

http://blog.paulbouwer.com/2010/01/31/replace-diffmerge-tool-in-visual-studio-team-system-with-winmerge/

will show you how to do this

查看更多
闹够了就滚
6楼-- · 2019-01-07 01:45

To compare any two files and merge it to one file Here are the following steps you can follow if you have visual studio(Any version) installed.

Step 1: Open Visual studio command prompt. If you do not find visual studio command prompt then choose visual studio tools

Start -> Visual studio command prompt

enter image description here

enter image description here

Step 2: Enter the command vsdiffmerge.exe

Ignore the switch /m if you need just comparison.

Syntax 1:
vsdiffmerge <file1> <file2> <file1> <outputfile> /t /m

Syntax 2:
vsdiffmerge <basefilename> <CompareFilename> <basefilename> <OutputFilename> /t /m

Example 1:
vsdiffmerge test1.js test2.js test1.js output.js /t /m
Example 2:
vsdiffmerge.exe "C:\Users\livingston\Downloads\wa\wa\Files\pre\Test.js" "C:\Users\livingston\Downloads\wa\wa\Files\Prod\Test.js" "C:\Users\livingston\Downloads\wa\wa\Files\pre\Test.js" "C:\Users\livingston\Downloads\wa\wa\Files\output\samp.js" /t /m

enter image description here


Step 3: Merge the files

enter image description here Please note that if file name does not exists in the location, it will not open the comparer.

Also you can beautify the file before you do the comparison. In visual studio Ctrl + K + D.

There are lot of beautifier sites available online.

查看更多
太酷不给撩
7楼-- · 2019-01-07 01:52

I had this problem as well. No TFS, but I found this article helpful.

Specifically, step 1b.

Open a Visual Studio command prompt and navigate to the Common7/IDE folder and type

tf diff /configure
查看更多
登录 后发表回答