powershelldebuggingvisual-studio-code

How do i set Environment Variables for Debugging PowerShell in Visual Studio Code?


I need to debug a PowerShell script that uses several environment variables. For practical reasons, I need to be able to change the variables on the fly, and it would be painful to have to restart Visual Studio Code every time I want to change the variables.

In Visual Studio, when debugging C++ code it is easy to set environment variables by configuring the debug settings of your Start Up Project.

I've also found another question that was answered, but it seems to apply specifically to how to configure Environment variables for debugging node.js projects. (How do I add environment variables to launch.json in VSCode)

Is there not a global way to configure environment variables for the Visual Studio Code Debugger?


Solution

  • It's not currently possible. See this open issue for the Powershell Plugin for Visual Studio Code: https://github.com/PowerShell/vscode-powershell/issues/1472