8000 Update vswhere usage by slide · Pull Request #1105 · pythonnet/pythonnet · GitHub
[go: up one dir, main page]

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 1 commit
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
Next Next commit
Update vswhere usage
Updates to newer version of vswhere.exe

Follows the recommended way of finding MSBuild.exe
from https://github.com/microsoft/vswhere#example

Also, updates to allow finding newer versions of VS.
  • Loading branch information
slide committed Apr 8, 2020
commit 51b857bbddef0af13f50339ebafd0e27645827fd
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.
0