Skip to content

Commit a557fe0

Browse files
committed
Add new "attach" and "interactive" debugging configurations
This change adds new configuration possibilies for PowerShell debugging in the extension. The first is simply to allow the user to not specify a script file in their "launch" configuration; when such a configuration is launched it merely drops them into an interactive shell in the Debug Console where they can enter whatever commands they like. The other new configuration is a new "attach" configuration which allows the user to specify a process ID or a remote computer and process ID to which the debugger should be attached when it launches. This provides a smooth attach/detach experience so that the user does not need to go into an interactive console to initiate the Enter-PSSession and Enter-PSHostProcess commands manually (though this is still possible and supported in interactive debugging mode).
1 parent 1a1b6e0 commit a557fe0

File tree

1 file changed

+52
-6
lines changed

1 file changed

+52
-6
lines changed

package.json

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@
160160

161161
"configurationSnippets": [
162162
{
163-
"label": "PowerShell: Launch Current File Configuration",
163+
"label": "PowerShell: Launch Current Script Configuration",
164164
"description": "A new configuration for launching the current opened PowerShell script",
165165
"body": {
166166
"type": "PowerShell",
@@ -172,7 +172,7 @@
172172
}
173173
},
174174
{
175-
"label": "PowerShell: Launch Configuration",
175+
"label": "PowerShell: Launch Script Configuration",
176176
"description": "A new configuration for launching a PowerShell script",
177177
"body": {
178178
"type": "PowerShell",
@@ -182,22 +182,39 @@
182182
"args": [],
183183
"cwd": "^\"\\${workspaceRoot}\""
184184
}
185+
},
186+
{
187+
"label": "PowerShell: Attach to PowerShell Process Configuration",
188+
"description": "A new configuration for debugging a runspace in another process.",
189+
"body": {
190+
"type": "PowerShell",
191+
"request": "attach",
192+
"name": "PowerShell Attach to Process",
193+
"processId": "${ProcessId}",
194+
"runspaceId": "1"
195+
}
196+
},
197+
{
198+
"label": "PowerShell: Launch Interactive Session Configuration",
199+
"description": "A new configuration for debugging an interactive session.",
200+
"body": {
201+
"type": "PowerShell",
202+
"request": "launch",
203+
"name": "PowerShell Interactive Session"
204+
}
185205
}
186206
],
187207

188208
"configurationAttributes": {
189209
"launch": {
190-
"required": [
191-
"script"
192-
],
193210
"properties": {
194211
"program": {
195212
"type": "string",
196213
"description": "Deprecated. Please use the 'script' property instead to specify the absolute path to the PowerShell script to launch under the debugger."
197214
},
198215
"script": {
199216
"type": "string",
200-
"description": "Absolute path to the PowerShell script to launch under the debugger."
217+
"description": "Optional: Absolute path to the PowerShell script to launch under the debugger."
201218
},
202219
"args": {
203220
"type": "array",
@@ -213,6 +230,23 @@
213230
"default": "${workspaceRoot}"
214231
}
215232
}
233+
},
234+
"attach": {
235+
"properties": {
236+
"computerName": {
237+
"type": "string",
238+
"description": "Optional: The computer name to which a remote session will be established. Works only on PowerShell 4 and above."
239+
},
240+
"processId": {
241+
"type": "number",
242+
"description": "The ID of the process to be attached. Works only on PowerShell 5 and above."
243+
},
244+
"runspaceId": {
245+
"type": "number",
246+
"description": "Optional: The ID of the runspace to debug in the attached process. Defaults to 1. Works only on PowerShell 5 and above.",
247+
"default": 1
248+
}
249+
}
216250
}
217251
},
218252
"initialConfigurations": [
@@ -223,6 +257,18 @@
223257
"script": "${file}",
224258
"args": [],
225259
"cwd": "${file}"
260+
},
261+
{
262+
"type": "PowerShell",
263+
"request": "attach",
264+
"name": "PowerShell Attach",
265+
"processId": "12345"
266+
},
267+
{
268+
"type": "PowerShell",
269+
"request": "launch",
270+
"name": "PowerShell Interactive Session",
271+
"cwd": "${workspaceRoot}"
226272
}
227273
]
228274
}

0 commit comments

Comments
 (0)