Skip to content

Commit 21ad2dc

Browse files
committed
more ways to find pwsh.exe on path
1 parent 1259e91 commit 21ad2dc

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

ecsact/repositories.bzl

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,22 @@ if($EcsactSdkInfo) {
133133
}
134134
"""
135135

136+
def _find_pwsh(rctx):
137+
pwsh = rctx.which("pwsh.exe")
138+
if pwsh:
139+
return pwsh
140+
141+
# rctx.which doesn't work for everything available on Windows. Using cmd's
142+
# built-in 'where' command can find programs installed from the Microsoft
143+
# store or MSIX packages.
144+
cmd = rctx.which("cmd.exe")
145+
if cmd:
146+
where_result = rctx.execute([cmd, "/C", "where pwsh.exe"])
147+
if where_result.stdout:
148+
return where_result.stdout
149+
150+
return None
151+
136152
def _ecsact_host_repo_impl(rctx):
137153
is_windows = rctx.os.name.startswith("windows")
138154
exe_extension = ""
@@ -144,7 +160,7 @@ def _ecsact_host_repo_impl(rctx):
144160
target_tool_path_runfiles = []
145161

146162
if ecsact_path == None and is_windows:
147-
pwsh = rctx.which("pwsh.exe")
163+
pwsh = _find_pwsh(rctx)
148164
if pwsh == None:
149165
fail("Cannot find pwsh.exe")
150166
rctx.file("FindEcsactSdk.ps1", _FIND_ECSACT_SDK_PWSH)

0 commit comments

Comments
 (0)