mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-07-30 13:47:46 +00:00
fix nu_msvs (#1116)
nu_msvs doesn't work at all on my setup, vswhere return empty string when called from nushell, the only way i made it to work is calling it from powershell on json parsing side installationPath is not an array, and vswhere return an array of installations is not correct e.g ```json [ { "instanceId": "406fd398", "installDate": "2024-04-25T13:16:29Z", "installationName": "VisualStudioPreview/17.14.0-pre.5.0+36025.13", "installationPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\Preview", "installationVersion": "17.14.36025.13", "productId": "Microsoft.VisualStudio.Product.BuildTools", "productPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\Preview\\Common7\\Tools\\LaunchDevCmd.bat", "state": 4294967295, "isComplete": true, "isLaunchable": true, "isPrerelease": true, "isRebootRequired": false, "displayName": "Visual Studio Build Tools 2022", "description": "Visual Studio Build Tools vous permet de générer des applications MSBuild natives et managées sans passer par l'IDE Visual Studio. Il existe des options pour installer les compilateurs et bibliothèques Visual C++, ainsi que la prise en charge d'ATL, de MFC et de C++/CLI.", "channelId": "VisualStudio.17.Preview", "channelUri": "https://aka.ms/vs/17/pre/channel", "enginePath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\resources\\app\\ServiceHub\\Services\\Microsoft.VisualStudio.Setup.Service", "installedChannelId": "VisualStudio.17.Preview", "installedChannelUri": "https://aka.ms/vs/17/pre/channel", "releaseNotes": "https://go.microsoft.com/fwlink/?LinkId=661273#17.14.0-pre.5.0", "resolvedInstallationPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\Preview", "thirdPartyNotices": "https://go.microsoft.com/fwlink/?LinkId=661288", "updateDate": "2025-04-29T20:49:54.8401699Z", "catalog": { "buildBranch": "d17.14", "buildVersion": "17.14.36025.13", "id": "VisualStudioPreview/17.14.0-pre.5.0+36025.13", "localBuild": "build-lab", "manifestName": "VisualStudioPreview", "manifestType": "installer", "productDisplayVersion": "17.14.0 Preview 5.0", "productLine": "Dev17", "productLineVersion": "2022", "productMilestone": "Preview", "productMilestoneIsPreRelease": "True", "productName": "Visual Studio", "productPatchVersion": "0", "productPreReleaseMilestoneSuffix": "5.0", "productSemanticVersion": "17.14.0-pre.5.0+36025.13", "requiredEngineVersion": "3.14.2074.57458" }, "properties": { "campaignId": "", "channelManifestId": "VisualStudio.17.Preview/17.14.0-pre.5.0+36025.13", "includeRecommended": "0", "nickname": "", "setupEngineFilePath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\setup.exe" } } ] ```
This commit is contained in:
parent
189c3d646e
commit
b2d512f6c6
1 changed files with 4 additions and 7 deletions
|
@ -3,21 +3,18 @@ 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 vswhere_cmd = ($'($env."ProgramFiles(x86)")\Microsoft Visual Studio\Installer\vswhere.exe')
|
||||
let info = (
|
||||
if ($vswhere_cmd | path exists) {
|
||||
(^$vswhere_cmd -format json | from json)
|
||||
(^$vswhere_cmd -prerelease -products '*' -format json -nocolor -utf8 -sort | from json)
|
||||
} else {
|
||||
# this should really error out here
|
||||
('{"installationPath": [""]}' | from json)
|
||||
('[{"installationPath": ""}]' | from json)
|
||||
}
|
||||
)
|
||||
|
||||
$env.MSVS_ROOT = $info.installationPath.0
|
||||
$env.MSVS_ROOT = $info.0.installationPath
|
||||
|
||||
$env.MSVS_MSVC_ROOT = (
|
||||
if not ($'($env.MSVS_ROOT)\VC\Tools\MSVC\' | path exists) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue