Search code examples
gitvisual-studiovisual-studio-2017team-explorer

Set Visual Studio source control provider in a script


Visual Studio 2017 has a setting for the source control provider (Team Foundation Server, Git, ...). Does anybody know how to set this setting from a script or where Visual Studio does store this setting?


Solution

  • The source control provider can be set using vsregedit.exe.

    To set Git as the source control provider from a PowerShell script:

    $vsWherePath = Join-Path ${env:ProgramFiles(x86)} "Microsoft Visual Studio\Installer\vswhere.exe"
    $vsVersion = "[15.0,16.0)"
    $installPath = &$vsWherePath -all -latest -version $vsVersion -property installationPath
    $vsregedit = Join-Path $installPath 'Common7\IDE\vsregedit.exe'
    
    
    &$vsregedit set "$installPath" HKCU CurrentSourceControlProvider `"`" string "{11B8E6D7-C08B-4385-B321-321078CDD1F8}"