Description
Prerequisites
- I have written a descriptive issue title.
- I have searched all open and closed issues to ensure it has not already been reported.
- I have read the troubleshooting guide.
- I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
- I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
- If this is a security issue, I have read the security issue reporting guidance.
Summary
#3259 was recently fixed so the integrated console doesn't change CWD when using "Run/Debug Tests". However there are still commands and config that enforces and promotes unnecessary CWD-changes.
-
PowerShell: Run
command (and it's Play-button in editor title bar) is hardcoded to change cwd to file's directorycwd: "${file}"
-
The suggested launch configuration also use
cwd: "${file}"
. However, debugging without launch config doesn't change cwd unless running in temporary console.
The first command should not change working directory in my opinion. The suggested launch config should also leave it unchanged (set to cwd: ""
). People can change it if they want/need it.
This change would also encourage users to rely on $PSScriptRoot
when referencing files relative to the script. I believe that's a good practice since working directory is rarely specified when running scripts in my experience.
PowerShell Version
Name Value
---- -----
PSVersion 7.2.5
PSEdition Core
GitCommitId 7.2.5
OS Microsoft Windows 10.0.22000
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visual Studio Code Version
1.70.0-insider
1cd90cceddf3c413673963ab6f154d2ff294b17c
x64
Extension Version
ms-vscode.powershell-preview@2022.7.0
Steps to Reproduce
Scenario 1:
- Create a powershell-file in a different directory than the integrated console's cwd/pwd
- Press the play-button or use
PowerShell: Run
command
Scenario 2:
- Add a launch configuration for
Launch current file
- Press F5 in a powershell-file that's placed in a different folder than the integrated console's cwd/pwd
The cwd/pwd in integrated console will be changed.
Visuals
No response
Logs
No response