Debugger not started when breakpoint is set in the editor
See original GitHub issueSystem Details
- Operating system name and version: Windows Server 2012 64 bit
- VS Code version: 1.15.0-insider
- PowerShell extension version: 1.4.1
- Output from
$PSVersionTable
: Name Value
PSVersion 5.1.14409. PSEdition Desktop PSCompatibleVersions {1.0, 2.0, BuildVersion 10.0.14409 CLRVersion 4.0.30319. WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1
Copy / paste the below commands into the PowerShell Integrated Terminal, and paste the output here
code -v
code : The term 'code' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the pa
th is correct and try again.
At line:1 char:1
+ code -v
+ ~~~~
+ CategoryInfo : ObjectNotFound: (code:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS S:\Prod> $pseditor.EditorServicesVersion
Major Minor Build Revision
----- ----- ----- --------
1 4 1 0
PS S:\Prod> code --list-extensions --show-versions
code : The term 'code' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the pa
th is correct and try again.
At line:1 char:1
+ code --list-extensions --show-versions
+ ~~~~
+ CategoryInfo : ObjectNotFound: (code:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Issue Description
The debugger is not started on a fresh start of vs code. Steps to reproduce the issue.
Step 1
Create file Testie.ps1
with content:
[CmdLetBinding()]
Param (
[Parameter(Mandatory)]
[String]$ProcessName
)
<# TESTs
$TestParams = @{
ProcessName = 'Code'
Verbose = $true
}
&'S:\Test\Brecht\Testie3.ps1' @TestParams
#>
Write-Verbose "Script started"
Get-Process | where Name -Like "$ProcessName*"
Write-Verbose "Debugging done"
Step 2
Set a breakpoint at line 16
by clicking F9
.
Step 3
Select the code in the comments and click F8
.
(The purpose of doing it this way is to have the parameter validation done)
Observe that the script is completely executed without stopping at line 16
. The current workaround is to run the whole script by clicking F5
and then doing step 3 again.
Issue Analytics
- State:
- Created 6 years ago
- Comments:9
Top GitHub Comments
I’ll try a different way of explaining what I mean. I’m using VSCode 1.19.0, which I believe is the current latest release.
In ISE:
PS> ise mystuff.psm1
)The steps as above in VSCode:
PS> code mystuff.psm1
) (no .vscode folder exists)I would consider this to be the “intuitive” behaviour, especially for someone coming from ISE.
Steps in VS Code to actually get it working. This is basically the I did when I was trying to figure out if I could get it working like ISE at all. Now I know how it works I can skip a few steps, but I believe this to be what someone coming from ISE is likely to also try.
Addition steps required are in bold.
PS> code mystuff.psm1
) (no .vscode folder)While I am sure there are limitations in what is possible in VS Code, given it’s a generic editor and not specifically a powershell editor, it surely must be possible to reduce the number of steps.
Even if you remember to open a folder and not a file directly, it’s still 10 steps, as opposed to the 5 in ISE before you can hit a breakpoint when using the console.
If there’s an easier way to do this, or a setting that I’m missing somehow, please let me know.
I’ve tried to read up on launch configurations but I’ve not figured the following out; would it be possible to “chain” two debugging configurations into one launch-configuration?
Lets say I have a script containing a function definition. I hit F5 and the launch configuration launches the “Powershell Launch Current File” to re-define the function in the runspace and directly after starts and leaves the debugger running according to the “Powershell Interactive Session”-launch configuration which would allow me to call the function from the integrated terminal only running one launch configuration instead of two different launch configurations after one another?
Does that make sense? 😃
(This would be a temporary solution until this enhancement gets implemented (if launch configurations support this “feature” that is)