How to configure Visual Studio to use Beyond Compa

2019-01-05 07:07发布

I would like to configure Visual Studio to open Beyond Compare by default as the diff tool. How can I do this?

9条回答
戒情不戒烟
2楼-- · 2019-01-05 07:37

I got bored of doing this every 6 months when a new version of Visual Studio comes out, or I move PCs, or a new member joins the team. So, 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'}
}

Works on my machine. YMMV. No warranties, no refunds. VS doesn't appear to cache the key, so takes effect immediately.

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

VS2013 on 64-bit Windows 7 requires these settings: Tools | Options | Source Control | Jazz Source Control

CHECK THE CHECKBOX Use an external compare tool ... (easy to miss this)

2-Way Compare Location of Executable: C:\Program Files (x86)\Beyond Compare 3\BCompare.exe

3-Way Conflict Compare Location of Executable: C:\Program Files (x86)\Beyond Compare 3\BCompare.exe

查看更多
不美不萌又怎样
4楼-- · 2019-01-05 07:38

The answer posted by @schellack is perfect for most scenarios, but I wanted Beyond Compare to simulate the '2 Way merge with a result panel' view that Visual Studio uses in its own merge window.

This config hides the middle panel (which is unused in most cases AFAIK).

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

With thanks to Morgen

查看更多
登录 后发表回答