From 27c9d2acc2957503c4a1cdd53ca6bfa6aac3265f Mon Sep 17 00:00:00 2001 From: Keith Hill Date: Sun, 5 Feb 2017 17:42:06 -0700 Subject: [PATCH 1/2] 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. --- examples/.vscode/launch.json | 11 ++++++++++- examples/DebugTest.ps1 | 8 ++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/examples/.vscode/launch.json b/examples/.vscode/launch.json index 4b77a9cf94..ef38b46228 100644 --- a/examples/.vscode/launch.json +++ b/examples/.vscode/launch.json @@ -4,7 +4,16 @@ { "type": "PowerShell", "request": "launch", - "name": "PowerShell Interactive Session" + "name": "PowerShell Launch (DebugTest.ps1)", + "script": "${workspaceRoot}/DebugTest.ps1", + "args": ["-Count 42 -DelayMilliseconds 1500"], + "cwd": "${workspaceRoot}" + }, + { + "type": "PowerShell", + "request": "launch", + "name": "PowerShell Interactive Session", + "cwd": "${workspaceRoot}" }, { "type": "PowerShell", diff --git a/examples/DebugTest.ps1 b/examples/DebugTest.ps1 index 6f14c1252a..ebd6ebb651 100644 --- a/examples/DebugTest.ps1 +++ b/examples/DebugTest.ps1 @@ -1,3 +1,5 @@ +param([int]$Count=50, [int]$DelayMilliseconds=200) + function Write-Item($itemCount) { $i = 1 @@ -10,7 +12,7 @@ function Write-Item($itemCount) { $i = $i + 1 # Slow down execution a bit so user can test the "Pause debugger" feature. - Start-Sleep -Milliseconds 200 + Start-Sleep -Milliseconds $DelayMilliseconds } } @@ -23,4 +25,6 @@ function Do-Work($workCount) { Write-Host "Done!" } -Do-Work 50 +$process = Get-Process -Id $pid + +Do-Work $Count From 033c52a901ed5b0bf767d994c4bec6eec596fba0 Mon Sep 17 00:00:00 2001 From: Keith Hill Date: Mon, 6 Feb 2017 08:53:31 -0700 Subject: [PATCH 2/2] Removed line that was used for testing. --- examples/DebugTest.ps1 | 2 -- 1 file changed, 2 deletions(-) diff --git a/examples/DebugTest.ps1 b/examples/DebugTest.ps1 index ebd6ebb651..478990bfd2 100644 --- a/examples/DebugTest.ps1 +++ b/examples/DebugTest.ps1 @@ -25,6 +25,4 @@ function Do-Work($workCount) { Write-Host "Done!" } -$process = Get-Process -Id $pid - Do-Work $Count