You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I also added the launch configuration as suggested in the linked issue:
{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "type": "PowerShell", "request": "launch", "name": "PowerShell Launch Current File From Workspace Folder", "script": "${file}", "args": [], "cwd": "${workspaceFolder}" }, ] }
When I debug the script from VScode (F5) an fill in the two mandatory arguments with whatever, I can inspect the values for :
$target = "....\Simulation" which is wrong, it should consist of the rooted path where my script is stored.
$PSScriptRoot = "", I guess that was expected, given that $target contains the wrong path. Still weird that PSScriptRoot for some reason is not populated....
but then... surprisingly enough , the $copyOfScriptRoot DOES have the correct rooted path of my script location. Wait, WUT?! how??
I double checked the powershell extension, I am using latest.
When I run the script from a powershell command window, it DOES populate $PSScriptRoot as expected.
Am I doing something wrong? Or is there still something broken with the annoying special behavior of populating $PSScriptRoot?
PS: I'd love to join discord for asking questions first, but I can't seem to login there. Hope you can forgive me for "dropping a bug" which might still be a user error on my side...
Copy paste the simplified example to c:\dev\PrepareSimFromRemote.ps1
open C:\dev in vscode (cd dev; code .)
ctrl + shift + p,
edit launch.json to
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "PowerShell",
"request": "launch",
"name": "PowerShell Launch Current File From Workspace Folder",
"script": "${file}",
"args": [],
"cwd": "${workspaceFolder}"
},
]
}
Open the PrepareSimFromRemote script
optionally: Put a breakpoint on any line in the script
Press F5
Observe that $PSScriptRoot is empty
Visuals
k
Logs
k
The text was updated successfully, but these errors were encountered:
Hey! You're far from the first to ask for this, while we agree it'd be great, we haven't identified a proper solution for it yet. Going to refer you to prior discussion in #633
Prerequisites
Summary
Very much similar to issue #1330 I am unable to use $PSScriptRoot as a default argument when I am running the script in the debugger with F5.
My simplified script:
`
param(
[parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$machineNumber,
[ValidateNotNullOrEmpty()] [string]$softwareFolder = "some path",
[ValidateNotNullOrEmpty()] [string]$target = "$PSScriptRoot....\Simulation",
[parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$version
)
Process
{
$copyOfPSScriptRoot = $PSScriptRoot
}
`
I also added the launch configuration as suggested in the linked issue:
{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "type": "PowerShell", "request": "launch", "name": "PowerShell Launch Current File From Workspace Folder", "script": "${file}", "args": [], "cwd": "${workspaceFolder}" }, ] }
When I debug the script from VScode (F5) an fill in the two mandatory arguments with whatever, I can inspect the values for :
I double checked the powershell extension, I am using latest.
When I run the script from a powershell command window, it DOES populate $PSScriptRoot as expected.
Am I doing something wrong? Or is there still something broken with the annoying special behavior of populating $PSScriptRoot?
PS: I'd love to join discord for asking questions first, but I can't seem to login there. Hope you can forgive me for "dropping a bug" which might still be a user error on my side...
PowerShell Version
Visual Studio Code Version
Extension Version
[email protected]
Steps to Reproduce
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "PowerShell",
"request": "launch",
"name": "PowerShell Launch Current File From Workspace Folder",
"script": "${file}",
"args": [],
"cwd": "${workspaceFolder}"
},
]
}
Visuals
k
Logs
k
The text was updated successfully, but these errors were encountered: