Why my working directory is modified by Launch-VsDevShell.ps1
and how can we prevent this from happening?
I'm writting a script building a C programm and I need MSVC on Windows.
MSVC tools (cl.exe, ...) are not definded in PATH by default and you need to execute Launch-VsDevShell.ps1
to get this tools.
After executting Launch-VsDevShell.ps1
in my script the current working directory is defined to C:\Users\USERNAME\source\repos
.
I just want Launch-VsDevShell.ps1
to add environement variable, not to change my pwd.
CodePudding user response:
You need to use -SkipAutomaticLocation
$vsWhere = "${Env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$vsInstallationPath = & $vsWhere -products * -latest -property installationPath
& "${vsInstallationPath}\Common7\Tools\Launch-VsDevShell.ps1" -Arch amd64 -SkipAutomaticLocation