# vs-utils.nu # Visual Studio environment management for Nushell export def --env vcvars [] { if ($env.VCINSTALLDIR? | is-not-empty) { print "Visual Studio environment already initialized." return } print "Initializing Visual Studio Developer Environment..." # Bridge to PowerShell to get the environment variables # The new pw7 function in env.nu already sources Gemini_Profile.ps1 let env_json = (pw7 ' $vsPath = & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath if ($vsPath) { $devShellModule = Get-ChildItem -Path "$vsPath\Common7\Tools" -Filter "Microsoft.VisualStudio.DevShell.dll" -Recurse | Select-Object -First 1 -ExpandProperty FullName if ($devShellModule) { Import-Module $devShellModule Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -Arch amd64 -NoLogo Get-ChildItem env: | ForEach-Object { @{ Name = $_.Name; Value = $_.Value } } | ConvertTo-Json } } ' | from json) if ($env_json | is-empty) { print "Error: Could not initialize Visual Studio environment." return } # Load the environment variables into Nushell let new_env = ($env_json | reduce -f {} {|it, acc| $acc | insert $it.Name $it.Value }) # Path handling load-env $new_env # Convert Path string from PS back to Nu List if necessary if ($env.Path? | is-not-empty) { $env.PATH = ($env.Path | split row (char esep)) } print "Visual Studio 2026 Developer Environment initialized." }