Reputation: 113
When deploying software with the Visual Studio redistributable 2015, if a more recent redistributable is found, the user is presented with a confusing dialog box that implies that something is wrong with the software.
To avoid this, when deploying software with the 2015 runtime, the developer must first check for the existence of more recent versions of the Visual Studio runtime, by polling the registry, and avoid the install attempt if a newer version is found.
For example, here are some checks on a 64 bit system for Visual Studio 2015/2017:
//Check for VS2015 on x86 architecture
if(installer.value("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\
VisualStudio\\14.0\\VC\\Runtimes\\x86\\Installed") == 1)
{
doInstall = false;
}
//Check for VS2017 on x86 architecture
if(installer.value("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\
VisualStudio\\15.0\\VC\\Runtimes\\x86\\Installed") == 1)
{
doInstall = false;
}
if(doInstall===true)
{ //Install }
(Written in Qt for installscript.qs)
You can see the check differs only by the version number, and this currently holds true for all the existing Visual Studio runtimes. I can poll any existing version of Visual Studio and confirm if that install is present by simply changing the version number.
So for now, it's a simple case of checking if 2015 or 2017 exist, and react accordingly.
The problem: After I have released my software, there will certainly be later versions of Visual Studio that I am not currently testing for. I need to future proof my release so that my installer does not attempt to install the Visual Studio 2015 redistributable if there is a hypothetical Visual Studio 2020 already present.
At the moment I feel the only solution is to add in a whole bunch of tests for these hypothetical Visual Studio versions, following the naming convention and going up to some large number that will cover the intended life of the program.
This looks like a Y2kbug type mistake. It feels like there should be a better way. I can't seem to find any posters even considered this problem, let alone solutions for it, so I'm guessing there must be some commonly known, obvious solution, that I'm just missing.
My best guess is that there might be a common registry key that simply indicates if 'any' Visual Studio product is installed, but I have yet to find one.
Upvotes: 0
Views: 74
Reputation: 297
I would personally regexp parse the version from the path VisualStudio\\**15.0**\\
and then test if myRequiredVersion>ParsedVersion. There is always a possibility that MS (or any company) goes haywire with naming conventions and change the whole path in the future, but that is the risk with everything really. You should maybe ask the user anyways whether he knows there is (newer) runtime/redistributable and allow installing even if you cannot find a proper match.
Upvotes: 1