Skip to content

Commit

Permalink
update vswhere location for nu_msvs (#882)
Browse files Browse the repository at this point in the history
This PR makes the location of vswhere more programmatic by looking where
it's supposed to be located on the file system instead of relying on it
being in your path.
  • Loading branch information
fdncred committed Jun 18, 2024
1 parent ddbebf1 commit 92db3a8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions modules/virtual_environments/nu_msvs/nu_msvs.nu
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@ def --env find_msvs [] {
$env.MSVS_BASE_PATH = $env.Path
$env.PATH_VAR = (if "Path" in $env { "Path" } else { "PATH" })

# This is a total hack because nushell doesn't like parentheses in an environment variable like `$env.ProgramFiles(x86)`
let programfiles = $env | transpose name value | where name starts-with Program and name ends-with '(x86)' | get value.0
# According to https://github.com/microsoft/vswhere/wiki/Installing, vswhere should always be in this location.
let vswhere_cmd = $'($programfiles)\Microsoft Visual Studio\Installer\vswhere.exe'

let info = (
if not (which vswhere | is-empty) {
(vswhere -format json | from json)
if ($vswhere_cmd | path exists) {
(^$vswhere_cmd -format json | from json)
} else {
# this should really error out here
('{"installationPath": [""]}' | from json)
}
)
Expand Down

0 comments on commit 92db3a8

Please sign in to comment.