如何配置Visual Studio使用超越比较

我想配置Visual Studio打开超越比较默认作为差异工具。我该怎么做呢?

166135 次浏览

在Visual Studio中,转到工具菜单,选择选项,展开源控制,(在TFS环境中,单击Visual Studio Team Foundation Server),然后单击配置用户工具按钮。

图片显示配置用户工具按钮的位置

单击添加按钮。

输入/选择以下比较选项:

  • 扩展: .*
  • 操作: Compare
  • 命令: C:\Program Files\Beyond Compare 3\BComp.exe(替换为您机器的正确路径,包括版本号)
  • 参数: %1 %2 /title1=%6 /title2=%7

如果使用Beyond Compare Professional (3-way Merge):

  • 扩展: .*
  • 操作: Merge
  • 命令: C:\Program Files\Beyond Compare 3\BComp.exe(替换为您机器的正确路径,包括版本号)
  • 参数: %1 %2 %3 %4 /title1=%6 /title2=%7 /title3=%8 /title4=%9

如果使用Beyond Compare v3/v4 Standard或Beyond Compare v2 (2-way Merge):

  • 扩展: .*
  • 操作: Merge
  • 命令: C:\Program Files\Beyond Compare 3\BComp.exe(替换为您机器的正确路径,包括版本号)
  • 参数: %1 %2 /savetarget=%4 /title1=%6 /title2=%7

如果你在Beyond Compare中使用标签

如果您以选项卡模式运行Beyond Compare,当您一次从Visual Studio中区分或合并多个文件集时,它可能会混淆。为了解决这个问题,你可以将参数/solo添加到参数的末尾;这确保了每次比较都在一个新窗口中打开,解决了选项卡的问题。

如果你正在使用TFS,你可以在Team Foundation中的diff/merge配置-常用命令和参数值中找到更多信息

介绍如何配置以下工具:

  • WinDiff
  • DiffDoc(适用于Word文件)
  • WinMerge
  • 无以伦比
  • KDiff3
  • Araxis
  • 比较它!
  • SourceGear DiffMerge
  • 无与伦比3
  • TortoiseMerge
  • 视觉SlickEdit

在Visual Studio 2008 +中,转到

Tools menu -->  select Options

enter image description here

在选项窗口中——> expand Source Control——>选择Subversion用户 >选择Beyond Compare

. >

单击“确定”按钮..

每隔6个月,每当Visual Studio的新版本出来,或者我移动电脑,或者有新成员加入团队时,我就会厌倦这样做。所以,PowerShell:

# .Synopsys
# Sets up Beyond Compare professional as Diff tool for all instances of Visual Studio on this PC
# If you don't use TFS, change the sccProvider as appropriate
[CmdLetBinding()]
param(
$bcPath = 'C:\Program Files (x86)\Beyond Compare 3\BComp.exe',
$sccProvider = 'TeamFoundation'
)


$ErrorActionPreference = 'stop';
$baseKey = 'REGISTRY::\HKCU\Software\Microsoft\VisualStudio\*'


function SetRegKeyProperties($keyPath, [hashtable]$keyProps){
if(!(Test-Path $keyPath)){
Write-Verbose "Creating $keyPath"
# Force required here to recursively create registry path
[void] (new-item $keyPath -Type:Directory -Force);
}
foreach($prop in $keyProps.GetEnumerator()){
Set-ItemProperty -Path:$keyPath -Name:$prop.Key -Value:$prop.Value;
}
}


$configBases = dir $baseKey | ? { $_.PSChildName -match '^\d+\.\d$' }
foreach($item in $configBases){
Write-Host "Configuring $item"


$diffToolsKey = Join-Path $item.PSPath "$sccProvider\SourceControl\DiffTools"
SetRegKeyProperties (Join-path $diffToolsKey '.*\Compare') @{Command=$bcPath;Arguments='%1 %2 /title1=%6 /title2=%7'}
SetRegKeyProperties (Join-path $diffToolsKey '.*\Merge') @{Command=$bcPath;Arguments='%1 %2 %3 %4 /title1=%6 /title2=%7 /title3=%8 /title4=%9'}
}

在我的机器上工作。YMMV。不保修,不退款。VS似乎没有缓存键,所以会立即生效。

VS2013在64位Windows 7上需要这些设置: 工具|选项|源码控制| Jazz源码控制

. zip

使用外部比较工具…(很容易忽略)

< p >双向比较 可执行文件位置:C:\Program Files (x86)\Beyond Compare 3\BCompare.exe

.exe

3-Way冲突比较 可执行文件位置:C:\Program Files (x86)\Beyond Compare 3\BCompare.exe

.exe

Visual Studio with Git for Windows

如果你使用GIT作为你的源代码管理系统,而不是(相当过时的)TFVC,那么Visual Studio没有选项来配置这样的东西 相反,它(在我看来是正确的)使用GIT配置文件的设置。因此,如果你已经安装了GIT,可以使用Beyond Compare或任何其他第三方比较软件,它就会选择并开始使用它

如果没有,那么就设置它(参见在这里以获得更多最新的帮助)。使用Beyond Compare 4设置Visual Studio的相关信息如下:

  1. 打开Visual Studio。
  2. 从“工具”菜单选择“选项”。
  3. 选择左侧树控件的“源代码控制”分支下的“插件设置”。
  4. 在右边窗格的插件设置下选择Microsoft Git Provider。
  5. 编辑全局git配置文件(位置是特定于windows的操作系统,它是%HOMEDRIVE%%HOMEPATH%/.gitconfig。或者如果你想在Git仓库中启动一个项目后,在项目文件夹中的. Git文件夹中编辑配置文件。
  6. 修改配置文件以反映以下变化:

    [diff]
    tool = bc4
    [difftool "bc4"]
    cmd = \"C:\\Program Files (x86)\\Beyond Compare 4\\BComp.exe\" \"$LOCAL\" \"$REMOTE\"
    [merge]
    tool = bc4
    [mergetool "bc4"]
    cmd = \"C:\\Program Files (x86)\\Beyond Compare 4\\BComp.exe\" \"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\"
    

If 64bit installer is used, verify the name of the executable. Mine was BCompare.exe

[diff]
tool = bc4
[difftool "bc4"]
cmd = \"C:\\Program Files\\Beyond Compare 4\\BCompare.exe\" \"$LOCAL\" \"$REMOTE\"
[merge]
tool = bc4
[mergetool "bc4"]
cmd = \"C:\\Program Files\\Beyond Compare 4\\BCompare.exe\" \"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\"
如果你创建了一个新项目,并获得VS来创建git repo at 与此同时,它将重载添加到.git/config文件 迫使它再次使用Visual Studio(感谢MS!) 因此,要么在项目建立后通过其他方式创建git回购 (比如通过SourceTree或命令行等等…)或者编辑.git/config文件 (在解决方案文件夹中)并删除上述设置的任何覆盖 感谢minnow在评论中再次让我注意到它

注意:我一直遇到这个问题,但我使用VS与GIT和 答案是不正确的,尽管一些评论提到了一个URL 正确的答案是不清楚的,如果我一直错过它,我 当然其他人会这样做,所以希望这将解决这个问题

BComp.exe也可以在多选项卡场景下工作,所以没有必要添加/solo,除非你真的想为每个文件比较单独的窗口。在Beyond Compare 3和4上测试/验证。寓意:使用BComp.exe,而不是BCompare.exe,用于VS外部比较工具配置。

我使用VS 2017与Git托管的项目在visualstudio.com托管(msdn)

上面的链接为我工作与“GITHUB for WINDOWS”指令。

http://www.scootersoftware.com/support.php?zz=kb_vcs#githubwindows

配置文件位于“c:\users\username\”的位置。gitconfig”,我只是根据我的情况将BC4更改为BC3,并使用适当的路径:

C:/Program Files (x86)/Beyond Compare 3/bcomp.exe

@schellack发布的答案对于大多数情况都是完美的,但我想要Beyond Compare来模拟Visual Studio在自己的合并窗口中使用的“2路合并与结果面板”视图。

这个配置隐藏了中间面板(在大多数情况下AFAIK没有使用)。

 %1 %2 "" %4 /title1=%6 /title2=%7 /title3="" /title4=%9

感谢摩根

我使用BC3作为我的git差异,但我也使用vscode添加到有用的git差异工具列表中。有些用户更喜欢vscode而不是vs ide的体验。

使用VS Code的Git差异

git config --global diff.tool vscode
git config --global difftool.vscode.cmd "code --wait --diff $LOCAL $REMOTE"

不能评论,因为我的声誉评分很低。

这里有一个到Fresky的链接的倒车链接