Skip to content

Update vswhere usage #1105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].
- Changed usage of obselete function GetDelegateForFunctionPointer(IntPtr, Type) to GetDelegateForFunctionPointer<TDelegate>(IntPtr)
- When calling C# from Python, enable passing argument of any type to a parameter of C# type `object` by wrapping it into `PyObject` instance. ([#881][i881])
- Added support for kwarg parameters when calling .NET methods from Python
- Changed method for finding MSBuild using vswhere

### Fixed

Expand Down
36 changes: 12 additions & 24 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,26 +457,20 @@ def _find_msbuild_tool(self, tool="msbuild.exe", use_windows_sdk=False):
# trying to search path with help of vswhere when MSBuild 15.0 and higher installed.
if tool == "msbuild.exe" and use_windows_sdk == False:
try:
basePathes = subprocess.check_output(
basePaths = subprocess.check_output(
[
"tools\\vswhere\\vswhere.exe",
"-latest",
"-version",
"[15.0, 16.0)",
"[15.0,)",
"-requires",
"Microsoft.Component.MSBuild",
"-property",
"InstallationPath",
"-find",
"MSBuild\**\Bin\MSBuild.exe",
]
).splitlines()
if len(basePathes):
return os.path.join(
basePathes[0].decode(sys.stdout.encoding or "utf-8"),
"MSBuild",
"15.0",
"Bin",
"MSBuild.exe",
)
if len(basePaths):
return basePaths[0].decode(sys.stdout.encoding or "utf-8")
except:
pass # keep trying to search by old method.

Expand Down Expand Up @@ -528,26 +522,20 @@ def _find_msbuild_tool(self, tool="msbuild.exe", use_windows_sdk=False):
def _find_msbuild_tool_15(self):
"""Return full path to one of the Microsoft build tools"""
try:
basePathes = subprocess.check_output(
basePaths = subprocess.check_output(
[
"tools\\vswhere\\vswhere.exe",
"-latest",
"-version",
"[15.0, 16.0)",
"[15.0,)",
"-requires",
"Microsoft.Component.MSBuild",
"-property",
"InstallationPath",
"-find",
"MSBuild\**\Bin\MSBuild.exe",
]
).splitlines()
if len(basePathes):
return os.path.join(
basePathes[0].decode(sys.stdout.encoding or "utf-8"),
"MSBuild",
"15.0",
"Bin",
"MSBuild.exe",
)
if len(basePaths):
return basePaths[0].decode(sys.stdout.encoding or "utf-8")
else:
raise RuntimeError("MSBuild >=15.0 could not be found.")
except subprocess.CalledProcessError as e:
Expand Down
Binary file modified tools/vswhere/vswhere.exe
Binary file not shown.