Skip to content

Commit 97a87d1

Browse files
author
minggo
committed
Merge pull request cocos2d#143 from natural-law/develop
Solve the error sometimes can't find correct VS path on windows.
2 parents 751afb6 + 8db198f commit 97a87d1

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

plugins/project_compile/project_compile.py

+17-16
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ def _get_vs_path(self, require_version):
713713

714714
try:
715715
for reg_flag in reg_flag_list:
716-
cocos.Logging.info("find vs in reg : %s" % "32bit" if reg_flag == _winreg.KEY_WOW64_32KEY else "64bit" )
716+
cocos.Logging.info("find vs in reg : %s" % ("32bit" if reg_flag == _winreg.KEY_WOW64_32KEY else "64bit"))
717717
vs = _winreg.OpenKey(
718718
_winreg.HKEY_LOCAL_MACHINE,
719719
r"SOFTWARE\Microsoft\VisualStudio",
@@ -724,25 +724,26 @@ def _get_vs_path(self, require_version):
724724
try:
725725
i = 0
726726
while True:
727-
# enum the keys in vs reg
728-
version = _winreg.EnumKey(vs, i)
729727
try:
728+
# enum the keys in vs reg
729+
version = _winreg.EnumKey(vs, i)
730730
find_ver = float(version)
731+
732+
# find the vs which version >= required version
733+
if find_ver >= float(require_version):
734+
key = _winreg.OpenKey(vs, r"SxS\VS7")
735+
vsPath, type = _winreg.QueryValueEx(key, version)
736+
737+
if os.path.exists(vsPath):
738+
if float(version) > float(require_version):
739+
needUpgrade = True
740+
break
741+
else:
742+
vsPath = None
731743
except:
732744
continue
733-
734-
# find the vs which version >= required version
735-
if find_ver >= float(require_version):
736-
key = _winreg.OpenKey(vs, r"SxS\VS7")
737-
vsPath, type = _winreg.QueryValueEx(key, version)
738-
739-
if os.path.exists(vsPath):
740-
if float(version) > float(require_version):
741-
needUpgrade = True
742-
break
743-
else:
744-
vsPath = None
745-
i += 1
745+
finally:
746+
i += 1
746747
except:
747748
pass
748749

0 commit comments

Comments
 (0)