Skip to content

Commit f27a311

Browse files
rkeithhilldaviwil
authored andcommitted
Add params to DebugTest.ps1. (PowerShell#485)
* Add params to DebugTest.ps1. This will align with part 2 of my debugging blog post for Scripting Guys. This allows testing of launch config that passes arguments and makes it easier to demo "attach to" but setting the delay a bit longer (say 2 secs). Also, updated launch.json to start with the default configuration before add tle Launch Script Configuration. * Removed line that was used for testing.
1 parent 05b75cb commit f27a311

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

examples/.vscode/launch.json

+10-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,16 @@
44
{
55
"type": "PowerShell",
66
"request": "launch",
7-
"name": "PowerShell Interactive Session"
7+
"name": "PowerShell Launch (DebugTest.ps1)",
8+
"script": "${workspaceRoot}/DebugTest.ps1",
9+
"args": ["-Count 42 -DelayMilliseconds 1500"],
10+
"cwd": "${workspaceRoot}"
11+
},
12+
{
13+
"type": "PowerShell",
14+
"request": "launch",
15+
"name": "PowerShell Interactive Session",
16+
"cwd": "${workspaceRoot}"
817
},
918
{
1019
"type": "PowerShell",

examples/DebugTest.ps1

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
param([int]$Count=50, [int]$DelayMilliseconds=200)
2+
13
function Write-Item($itemCount) {
24
$i = 1
35

@@ -10,7 +12,7 @@ function Write-Item($itemCount) {
1012
$i = $i + 1
1113

1214
# Slow down execution a bit so user can test the "Pause debugger" feature.
13-
Start-Sleep -Milliseconds 200
15+
Start-Sleep -Milliseconds $DelayMilliseconds
1416
}
1517
}
1618

@@ -23,4 +25,4 @@ function Do-Work($workCount) {
2325
Write-Host "Done!"
2426
}
2527

26-
Do-Work 50
28+
Do-Work $Count

0 commit comments

Comments
 (0)