Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Find out where Visual Studio is installed, with VSWhere


2 replies to this topic

GunSun

GunSun
  • Full Members
  • 4 posts

Posted 20 October 2017 - 11:09

Starting with Visual Studio 2017 it is not possible to look in the registry where Visual Studio is installed (and if it is installed), if you need to use this path as INSTALLDIR. Instead we are required to run a tool called VSWhere, which is installed in [ProgramFilesFolder]\Microsoft Visual Studio\Installer to find out.

 

I am using InstallShield 2015.

 

My first idea was to use a Prerequisite to check for the presence of VSWhere and run the VSWhere.exe with some parameters to get an xml file generated:

vswhere.exe -latest -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -all -products * -property installationPath -format xml > [TempFolder]\HereIsVS.xml

Then I would use a System Search to extract the installationPath from the xml file.

But, it seemed like a Prerequisite could not call an exe already present on the target system. It needed to be included in the PreReq package.

 

So, I tried plan B:
First run a custom action to run the command to generate the xml file and then use a System Search to extract the installationPath from the xml file.
But it seems like it is not possible to run an exe already present on the target system.

 

Now I am out of ideas. Was anyone else able to find a working strategy? Please share!



deramor

deramor
  • Full Members
  • 187 posts

Posted 20 October 2017 - 19:41

Sounds like it might be useful to write an Installscript custom action that first executes the vswhere then reads its output.  Once it knows where VS2017 is located, it can set a property you can later use to set a directory entry. 



GunSun

GunSun
  • Full Members
  • 4 posts

Posted 25 October 2017 - 14:31

The solution to the problem was to put the command in a batch file.

For the prereq this was required because something had to be shipped.

For the custom action it was not allowed to redirect output to a file using >, but calling a batch file doing the redirection was OK.

 

So what I did was to write a setup prereq that runs the batch file with the command, to create an xml file.

Then I used a system search to get the installation path from the xml file into a property, which was then used as installation path (if it was set).