fix VS version selection

On machines where multiple versions of VS are installed, the VS version
for the vc(x)proj generator is selected by the entries in the PATH
variable. The first VS installation that's found in PATH is used.

The former logic printed a warning if multiple VS installations were in
PATH and also fell back to the lowest version if a VS version was
registered with multiple install paths.
That's the case for VC 2012 express and prevented its usage.

Task-number: QTBUG-34357
Change-Id: Ia5c66a1aea0c40e4b7460b3aa6c7daee6673da44
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
This commit is contained in:
Joerg Bornemann 2013-10-29 16:09:18 +01:00 committed by The Qt Project
parent 67c9b5ad9f
commit 392054d311

View File

@ -124,17 +124,17 @@ DotNET which_dotnet_version()
// Fallback to .NET 2002
current_version = NET2002;
QStringList warnPath;
const DotNetCombo *lowestInstalledVersion = 0;
QHash<DotNET, QString> installPaths;
int installed = 0;
int i = 0;
for(; dotNetCombo[i].version; ++i) {
QString path = qt_readRegistryKey(HKEY_LOCAL_MACHINE, dotNetCombo[i].regKey);
if (!path.isEmpty() && installPaths.value(dotNetCombo[i].version) != path) {
installPaths.insert(dotNetCombo[i].version, path);
lowestInstalledVersion = &dotNetCombo[i];
installPaths.insert(lowestInstalledVersion->version, path);
++installed;
current_version = dotNetCombo[i].version;
warnPath += QString("%1").arg(dotNetCombo[i].versionStr);
current_version = lowestInstalledVersion->version;
}
}
@ -143,35 +143,20 @@ DotNET which_dotnet_version()
// More than one version installed, search directory path
QString paths = qgetenv("PATH");
QStringList pathlist = paths.toLower().split(";");
i = installed = 0;
for(; dotNetCombo[i].version; ++i) {
QString productPath = qt_readRegistryKey(HKEY_LOCAL_MACHINE, dotNetCombo[i].regKey).toLower();
if (productPath.isEmpty())
continue;
QStringList::iterator it;
for(it = pathlist.begin(); it != pathlist.end(); ++it) {
if((*it).contains(productPath)) {
++installed;
current_version = dotNetCombo[i].version;
warnPath += QString("%1 in path").arg(dotNetCombo[i].versionStr);
break;
}
const QStringList pathlist = paths.split(QLatin1Char(';'));
foreach (const QString &path, pathlist) {
for (i = 0; dotNetCombo[i].version; ++i) {
const QString productPath = installPaths.value(dotNetCombo[i].version);
if (productPath.isEmpty())
continue;
if (path.startsWith(productPath, Qt::CaseInsensitive))
return dotNetCombo[i].version;
}
}
switch(installed) {
case 1:
break;
case 0:
warn_msg(WarnLogic, "Generator: MSVC.NET: Found more than one version of Visual Studio, but"
" none in your path! Fallback to lowest version (%s)", warnPath.join(", ").toLatin1().data());
break;
default:
warn_msg(WarnLogic, "Generator: MSVC.NET: Found more than one version of Visual Studio in"
" your path! Fallback to lowest version (%s)", warnPath.join(", ").toLatin1().data());
break;
}
warn_msg(WarnLogic, "Generator: MSVC.NET: Found more than one version of Visual Studio, but"
" none in your PATH. Falling back to lowest version (%s)",
qPrintable(lowestInstalledVersion->versionStr));
return current_version;
#endif