Skip to content

Commit f1229bd

Browse files
author
dse
committed
Fix for the #539 classic build fails when VS 2017 installed.
1 parent 319dfe4 commit f1229bd

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
@@ -324,6 +324,20 @@ def _install_packages(self):
324324

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

0 commit comments

Comments
 (0)