1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-01 06:37:46 +00:00

update vswhere location for nu_msvs (#882)

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.
This commit is contained in:
Darren Schroeder 2024-06-18 09:19:02 -05:00 committed by GitHub
parent ddbebf197d
commit 92db3a88eb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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)
}
)