Programmatically finding the VS2017 installation directory

前端 未结 10 1219
梦谈多话
梦谈多话 2020-12-06 17:49

With previous versions of VS you could query the registry to determine the installation directory for VS:

HKLM\\SOFTWARE\\Wow6432Node\\Microsoft\\Visu

10条回答
  •  悲&欢浪女
    2020-12-06 18:45

    You can use this PowerShell snippet for finding the VS2017 installation directory:

    $vssetup_path = "$([Environment]::GetFolderPath("MyDocuments"))\WindowsPowerShell\Modules\VSSetup"
    if (-not (Test-Path $vssetup_path -pathType container))
    {
        iwr https://github.com/Microsoft/vssetup.powershell/releases/download/1.0.36-rc/VSSetup.zip -OutFile "$env:TEMP\VSSetup.zip"
        Expand-Archive "$env:TEMP\VSSetup.zip" $vssetup_path
    }
    $vs2017 = Get-VSSetupInstance -All | Select-VSSetupInstance -Require 'Microsoft.VisualStudio.Workload.NativeDesktop' -Version '[15.0,16.0)' -Latest
    "Installation Path: " + $vs2017.InstallationPath
    #`vsdevcmd.bat -arch=x86` or `vsdevcmd.bat -arch=amd64` can be used to setup path's to VC++ compiler
    "VsDevCmd.bat Path: " + $vs2017.InstallationPath + "\Common7\Tools\VsDevCmd.bat"
    

提交回复
热议问题