Author Topic: cannot find visual studio install path for version 15.0  (Read 894 times)

tyano

  • Community Member
  • Posts: 33
  • Hero Points: 1
cannot find visual studio install path for version 15.0
« on: December 30, 2019, 06:08:36 am »
I am using:
SlickEdit Pro 24.0.1.0
Visual Studio 2019 Community
I opend the VS2019's solution, VS shows the message:
cannot find visual studio install path for version 15.0
and I cannot build the VS2019 project with the message:
vsbuild: File not found (msbuild)
Is there any way to resolve this problem ?

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5149
  • Hero Points: 425
Re: cannot find visual studio install path for version 15.0
« Reply #1 on: December 30, 2019, 09:18:46 pm »
As a work around, try starting SlickEdit from a command prompt with the Visual Studio environment variables already setup (PATH, etc.).  Not sure if the community edition has a Start menu item which starts a pre-setup command prompt like the non-community version.

We will look into this.

Rodney

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 750
  • Hero Points: 47
Re: cannot find visual studio install path for version 15.0
« Reply #2 on: December 30, 2019, 10:15:32 pm »
@tyano
Please correct the email address in your profile. You will not receive topic notification emails until you do so.

++rodney

jporkkahtc

  • Senior Community Member
  • Posts: 1901
  • Hero Points: 184
  • Text
Re: cannot find visual studio install path for version 15.0
« Reply #3 on: December 30, 2019, 11:45:57 pm »
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:
Code: [Select]
    "%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-2019
That 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
Code: [Select]
: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:
Code: [Select]
:: 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


Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5149
  • Hero Points: 425
Re: cannot find visual studio install path for version 15.0
« Reply #4 on: December 31, 2019, 12:35:23 am »
Thanks. This information might be useful.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5149
  • Hero Points: 425
Re: cannot find visual studio install path for version 15.0
« Reply #5 on: December 31, 2019, 02:13:43 am »
SlickEdit already uses vswhere.exe but it needs to be present on your system.

I just installed Visual Studio 2019 Community edition. It installed vswhere.exe for me (I didn't have it before the install). For me, SlickEdit had no problem finding the "Visual Studio install path" from running vswhere.exe. I created a 2019 C++ project, opened the solution in SlickEdit, and it found msbuild/built just fine.

SlickEdit runs vswhere.exe as follows:

"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"  -utf8 -all -prerelease -requires Microsoft.Component.MSBuild -format xml

Is vswhere.exe installed on your system at %ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe?

jporkkahtc

  • Senior Community Member
  • Posts: 1901
  • Hero Points: 184
  • Text
Re: cannot find visual studio install path for version 15.0
« Reply #6 on: December 31, 2019, 10:25:32 pm »
Yes, I have vswhere.
When I start Slick, it doesn't appear to try to run it though -- according to Procmon anyways.
Attached a copy of the vswhere output.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5149
  • Hero Points: 425
Re: cannot find visual studio install path for version 15.0
« Reply #7 on: December 31, 2019, 10:42:42 pm »
Can you upload your solution and project?

I’m wondering if it’s not detecting the version correctly.

You could put say(“got here”) calls in the query_vswhere() function. It’s supposed to be called.

jporkkahtc

  • Senior Community Member
  • Posts: 1901
  • Hero Points: 184
  • Text
Re: cannot find visual studio install path for version 15.0
« Reply #8 on: December 31, 2019, 11:00:28 pm »
I emailed the project files to you.

jporkkahtc

  • Senior Community Member
  • Posts: 1901
  • Hero Points: 184
  • Text
Re: cannot find visual studio install path for version 15.0
« Reply #9 on: December 31, 2019, 11:11:20 pm »
Ok, so in _getVStudioInstallPath2017(), it returns here (line 2200)
Code: [Select]
   // no matching
   if (matches._isempty()) {
      return "";
   }

VS2019 is happy to load the project, build and run it.
I don't have VS2017 installed anymore.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5149
  • Hero Points: 425
Re: cannot find visual studio install path for version 15.0
« Reply #10 on: December 31, 2019, 11:56:59 pm »
Your vswhere.txt output doesn't show that Visual Studio 2017 is installed. Was it installed when you ran it?

jporkkahtc

  • Senior Community Member
  • Posts: 1901
  • Hero Points: 184
  • Text
Re: cannot find visual studio install path for version 15.0
« Reply #11 on: January 01, 2020, 12:03:25 am »
VS2017 is not installed.
Slickedit started giving that error message after I uninstalled vs2017.

I have only vs2019 installed.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5149
  • Hero Points: 425
Re: cannot find visual studio install path for version 15.0
« Reply #12 on: January 01, 2020, 02:23:52 am »
There are two issues.

One issue is that SlickEdit is saving the installed versions of Visual Studio across edit sessions. You can work around this by deleting your local "vslick.sta". This will be easy to hot fix.

The second problem is more of a pain. Microsoft NEVER upgrades solution files. If you created a solution in Visual Studio 2017, uninstall 2017, open that solution in Visual Studio 2019, then open the solution in SlickEdit,  SlickEdit will create the projects incorrectly using "devenv" instead of "msbuild".

As a work around, you can manual edit the solution file and change the version.

Here are the top two lines you need for a Visual Studio 2019 solution
Code: [Select]
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16

You definitely need the "#" line information. That's the one SlickEdit uses to determine which installed compiler to use.

In addition, you will need to delete the existing .vpw and .vpj. That way, SlickEdit will recreate them correctly, when you open the solution.

It's unlikely we will try to auto-upgrade the SlickEdit projects. However, SlickEdit should ONLY choose a version of Visual Studio which exists. Sounds easy to fix but it's not. Working on it now.

jporkkahtc

  • Senior Community Member
  • Posts: 1901
  • Hero Points: 184
  • Text
Re: cannot find visual studio install path for version 15.0
« Reply #13 on: January 01, 2020, 03:01:17 am »
#1 I wonder if it is possible to have a solution with 2 projects that require different versions of the build tools?

#2 Also, will slick support loading a solution when VisualStudio is not installed - but the build tools are installed?
Look for "Build Tools" here: https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2017.
(This is useful for a build-lab type thing, or if you just really hate even having visual studio installed - not sure if it is a useful scenario for Slick to worry about).

#3 Things like this make me wonder...
How in the heck do you keep track of all this crazy stuff across all the build tools and languages that Slick supports?
After struggling with crazy gradle stuff last year, now I'm trying to get up to speed on msbuild+visual studio projects.

MSbuild seems really badly documented. I guess the pure volume of the documentation is large, but trying to pull answers for specific problems out of it is really difficult.
I've been fighting with the differences between new style "<Project SDK" type csproj files vs the old style "<Project ToolsVersion" ones having lots of subtle (and not so subtle), and also the variations involved with nuget (sdk vs old style, vs old style + packagereference -- ugh).

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5149
  • Hero Points: 425
Re: cannot find visual studio install path for version 15.0
« Reply #14 on: January 01, 2020, 03:52:58 am »
#1 Right now, SlickEdit doesn't support that case.

#2  SlickEdit needs to know which Visual Studio project template to use when creating the .vpj files. There is a def_use_visual_studio_version variable. It isn't being used in enough places right now. I'm making fixes to that. Once fixed, you could set up the environment for SlickEdit and force SlickEdit to use a specific version for the project templates. Then I think this should work.

#3 It's pretty hard. The real problem is that everyone rolls there own everything. Worse yet, companies like Microsoft drastically changes there projects/build tools with new versions which breaks everything.