I get this too.
I recently uninstalled VS2017.
I have only VS2019 community installed.
From a CMD.exe I did this:
> set path=%PATH%;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE
> vs.exe
And I get the error:
---------------------------
SlickEdit Pro
---------------------------
Cannot find Visual Studio install path for version: 15
---------------------------
OK
---------------------------
If I open "Developer Command Prompt for VS 2019" - which runs "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat"
first, then I do not get this error.
...
I have recently dug into this for my own purposes.
What I have found, is that for VS2017 and later, "vswhere.exe" should be used, as in:
"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -property installationPath
See this:
https://docs.microsoft.com/en-us/visualstudio/install/tools-for-managing-visual-studio-instances?view=vs-2019That also has a powershell module and a C/C++ example for finding VS2017 and later.
For MSBUILD (2017 and later) tools only, I couldn't find a great way to do this - but just look in Programfiles
:CheckBuildTools %1
set BUILD_VER=%1
if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\%BUILD_VER%\BuildTools\MSBuild\Current\Bin\amd64\MSBuild.exe" (
set MSBUILD="%ProgramFiles(x86)%\Microsoft Visual Studio\%BUILD_VER%\BuildTools\MSBuild\Current\Bin\amd64\MSBuild.exe"
exit /b 0
)
if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\%BUILD_VER%\BuildTools\MSBuild\Current\Bin\MSBuild.exe" (
set MSBUILD="%ProgramFiles(x86)%\Microsoft Visual Studio\%BUILD_VER%\BuildTools\MSBuild\Current\Bin\MSBuild.exe"
exit /b 0
)
exit /b 1
For older versions of visual studio (before 2017) - I found this on stackoverflow:
:: Find the most recent version of MSBuild installed with Visual Studio (2015 and older)
for %%v in (15.0 14.0 13.0 12.0 4.0 3.5 2.0) do (
call :ReadMSBuildRegistry HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\%%v
if defined MSBUILD goto :EndLoop
)
:EndLoop
if not defined MSBUILD & echo MSBuild not found & set MSBUILD=& exit /b 1
:: Return with MSBUILD set in the parent environment
set MSBUILD=%MSBUILD%& echo MSBUILD is %MSBUILD% & goto :EOF
goto :EOF
:ReadMSBuildRegistry
for /f "tokens=1,2*" %%b in ('reg query "%1" /v MSBuildToolsPath 2^>nul ^| findstr MSBuildToolsPath') do set MSBUILD="%%d\msbuild.exe"
goto :EOF