MCPcopy Create free account
hub / github.com/nodejs/node / _DetectVisualStudioVersions

Function _DetectVisualStudioVersions

tools/gyp/pylib/gyp/MSVSVersion.py:456–546  ·  view source on GitHub ↗

Collect the list of installed visual studio versions. Returns: A list of visual studio versions installed in descending order of usage preference. Base this on the registry and a quick check if devenv.exe exists. Possibilities are: 2005(e) - Visual Studio 2005 (8

(versions_to_check, force_express)

Source from the content-addressed store, hash-verified

454
455
456def _DetectVisualStudioVersions(versions_to_check, force_express):
457 """Collect the list of installed visual studio versions.
458
459 Returns:
460 A list of visual studio versions installed in descending order of
461 usage preference.
462 Base this on the registry and a quick check if devenv.exe exists.
463 Possibilities are:
464 2005(e) - Visual Studio 2005 (8)
465 2008(e) - Visual Studio 2008 (9)
466 2010(e) - Visual Studio 2010 (10)
467 2012(e) - Visual Studio 2012 (11)
468 2013(e) - Visual Studio 2013 (12)
469 2015 - Visual Studio 2015 (14)
470 2017 - Visual Studio 2017 (15)
471 2019 - Visual Studio 2019 (16)
472 2022 - Visual Studio 2022 (17)
473 Where (e) is e for express editions of MSVS and blank otherwise.
474 """
475 version_to_year = {
476 "8.0": "2005",
477 "9.0": "2008",
478 "10.0": "2010",
479 "11.0": "2012",
480 "12.0": "2013",
481 "14.0": "2015",
482 "15.0": "2017",
483 "16.0": "2019",
484 "17.0": "2022",
485 "18.0": "2026",
486 }
487 versions = []
488 for version in versions_to_check:
489 # Old method of searching for which VS version is installed
490 # We don't use the 2010-encouraged-way because we also want to get the
491 # path to the binaries, which it doesn't offer.
492 keys = [
493 r"HKLM\Software\Microsoft\VisualStudio\%s" % version,
494 r"HKLM\Software\Wow6432Node\Microsoft\VisualStudio\%s" % version,
495 r"HKLM\Software\Microsoft\VCExpress\%s" % version,
496 r"HKLM\Software\Wow6432Node\Microsoft\VCExpress\%s" % version,
497 ]
498 for index in range(len(keys)):
499 path = _RegistryGetValue(keys[index], "InstallDir")
500 if not path:
501 continue
502 path = _ConvertToCygpath(path)
503 # Check for full.
504 full_path = os.path.join(path, "devenv.exe")
505 express_path = os.path.join(path, "*express.exe")
506 if not force_express and os.path.exists(full_path):
507 # Add this one.
508 versions.append(
509 _CreateVersion(
510 version_to_year[version], os.path.join(path, "..", "..")
511 )
512 )
513 # Check for express.

Callers 1

Calls 8

_RegistryGetValueFunction · 0.85
_ConvertToCygpathFunction · 0.85
_CreateVersionFunction · 0.85
globMethod · 0.80
rangeFunction · 0.50
joinMethod · 0.45
existsMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected