Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f911db4

Browse files
author
dse
committed
Fix for the #539 classic build fails when VS 2017 installed.
1 parent 8e0e244 commit f911db4

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

setup.py

+14
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,20 @@ def _install_packages(self):
323323

324324
def _find_msbuild_tool(self, tool="msbuild.exe", use_windows_sdk=False):
325325
"""Return full path to one of the Microsoft build tools"""
326+
327+
# trying to search path with help of vswhere when MSBuild 15.0 and higher installed.
328+
if use_windows_sdk==False:
329+
try:
330+
basePathes = subprocess.check_output(
331+
["tools\\vswhere\\vswhere.exe", "-latest",
332+
"-version", "[15.0, 16.0)",
333+
"-requires", "Microsoft.Component.MSBuild",
334+
"-property", "InstallationPath"]).splitlines()
335+
if len(basePathes):
336+
return os.path.join(basePathes[0].decode(sys.stdout.encoding or "utf-8"), "MSBuild", "15.0", "Bin", "MSBuild.exe")
337+
except:
338+
pass # keep trying to search by old method.
339+
326340
# Search in PATH first
327341
path = spawn.find_executable(tool)
328342
if path:

0 commit comments

Comments
 (0)