Skip to content

Commit dd2aa56

Browse files
committed
fix nu_msvs
1 parent 4ecbb0e commit dd2aa56

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

modules/virtual_environments/nu_msvs/nu_msvs.nu

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,21 @@ def --env find_msvs [] {
44
$env.PATH_VAR = (if "Path" in $env { "Path" } else { "PATH" })
55

66
# This is a total hack because nushell doesn't like parentheses in an environment variable like `$env.ProgramFiles(x86)`
7-
let programfiles = $env | transpose name value | where name starts-with Program and name ends-with '(x86)' | get value.0
7+
let programfiles = $env | transpose name value | where name starts-with Program and name ends-with '(x86)' | get value.0 | str trim
88
# According to https://github.com/microsoft/vswhere/wiki/Installing, vswhere should always be in this location.
9-
let vswhere_cmd = $'($programfiles)\Microsoft Visual Studio\Installer\vswhere.exe'
10-
9+
let vswhere_cmd = ($'($programfiles)\Microsoft Visual Studio\Installer\vswhere.exe')
10+
# Escape spaces and parenthesis with ` for powershell
11+
let vswhere_cmd_ps = ($vswhere_cmd | str replace -a ' ' '` ' | str replace -a '(' '`(' | str replace -a ')' '`)')
1112
let info = (
1213
if ($vswhere_cmd | path exists) {
13-
(^$vswhere_cmd -format json | from json)
14+
(powershell -NoLogo -NoProfile -NonInteractive -Command $'($vswhere_cmd_ps) -prerelease -products * -format json -nocolor -utf8 -sort' | from json)
1415
} else {
1516
# this should really error out here
16-
('{"installationPath": [""]}' | from json)
17+
('[{"installationPath": ""}]' | from json)
1718
}
1819
)
1920

20-
$env.MSVS_ROOT = $info.installationPath.0
21+
$env.MSVS_ROOT = $info.0.installationPath
2122

2223
$env.MSVS_MSVC_ROOT = (
2324
if not ($'($env.MSVS_ROOT)\VC\Tools\MSVC\' | path exists) {

0 commit comments

Comments
 (0)