我想配置Visual Studio打开超越比较默认作为差异工具。我该怎么做呢?
当前回答
每隔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似乎没有缓存键,所以会立即生效。
其他回答
Visual Studio with Git for Windows
如果你使用GIT作为你的源代码管理系统,而不是(相当过时的)TFVC,那么Visual Studio就没有选项来配置这样的东西。 相反,它(在我看来)使用了GIT配置文件的设置。因此,如果你已经安装了GIT,可以使用Beyond Compare或任何其他第三方比较软件,它就会选择这个并开始使用它。
如果没有,那就设置一下(参见这里获得更多最新的帮助)。使用Beyond Compare 4设置Visual Studio的相关信息如下:
Open Visual Studio. Select Options from the Tools menu. Select Plug-In Settings under the Source Control branch of the left-side tree control. Select Microsoft Git Provider under Plug-In Settings on the right-hand pane. Edit the global git config file (location is OS specific for windows it's %HOMEDRIVE%%HOMEPATH%/.gitconfig. See here for info) OR if you want it to be repo specifict then after starting a project in a Git repository, edit the config file in the .git folder in the project folder. Change the config file to reflect the following changes: [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\"
如果使用64位安装程序,请验证可执行文件的名称。我的 是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\"
Issues: If you create a new project and get VS to create the git repo at the same time it WILL add a load of overrides to the .git/config file forcing it to use Visual Studio again (Thanks for that MS!). SO either create the git repo via another means after the project has been setup (like via SourceTree or the command line etc...) OR edit the .git/config file (in the solution folder) and remove any overrides for the above settings. Thanks to minnow in the comments for bringing my attention to it again.
注意:我一直遇到这种情况,但我使用VS与GIT和 答案是不正确的,尽管一些评论提到了一个URL 正确的答案是不清楚的,如果我一直错过它,我 当然其他人会这样做,所以希望这将解决这个问题。
BComp.exe也可以在多选项卡场景下工作,所以没有必要添加/solo,除非你真的想为每个文件比较单独的窗口。在Beyond Compare 3和4上测试/验证。寓意:使用BComp.exe,而不是BCompare.exe,用于VS外部比较工具配置。
64位Windows 7上的VS2013需要这些设置: 工具|选项|源码控制| Jazz源码控制
使用外部比较工具…(很容易忽略)
双向比较 可执行文件位置:C:\Program Files (x86)\Beyond Compare 3\BCompare.exe
三向冲突比较 可执行文件位置:C:\Program Files (x86)\Beyond Compare 3\BCompare.exe
我使用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"
每隔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似乎没有缓存键,所以会立即生效。
推荐文章
- Visual Studio代码如何解决合并冲突与git?
- _references.js是用来做什么的?
- 如何为新的c#类/接口编辑Visual Studio模板?
- IIS Express Windows身份验证
- 配置系统初始化失败
- 在Visual Studio中是否有标准的快捷键来构建当前项目?
- 我如何让我的解决方案在Visual Studio回到在线的TFS?
- 如何在Visual Studio中生成getter和setter ?
- Visual Studio后构建事件-复制到相对目录位置
- 指定的参数超出有效值范围。参数名称:site
- 如何使用MS Visual Studio进行Android开发?
- 在安装了Resharper的Visual Studio中,键盘快捷键不活跃
- 在Visual Studio中如何在项目/解决方案之间共享代码?
- 用于自动添加“using”语句的Visual Studio键盘快捷方式
- Resharper Alt Enter不工作