Skip to content

Commit da5047d

Browse files
Update VS Code PowerShell Additional Exe Paths instructions (#9206)
* Update VS Code PowerShell Additional Exe Paths instructions Unfortunately a breaking change was introduced that we are not reverting, and so these instructions need to be updated. * Edit pass Co-authored-by: Sean Wheeler <[email protected]>
1 parent 22cbb0b commit da5047d

File tree

1 file changed

+42
-40
lines changed

1 file changed

+42
-40
lines changed

reference/docs-conceptual/dev-cross-plat/vscode/using-vscode.md

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
description: Using Visual Studio Code for PowerShell Development
3-
ms.date: 10/22/2021
3+
ms.date: 09/09/2022
44
title: Using Visual Studio Code for PowerShell Development
55
---
66

@@ -17,7 +17,7 @@ It supports the following PowerShell versions:
1717
- Windows PowerShell 5.1 (Windows-only)
1818

1919
> [!NOTE]
20-
> Visual Studio Code is not the same as [Visual Studio][vsent].
20+
> Visual Studio Code isn't the same as [Visual Studio][vsent].
2121
2222
## Getting started
2323

@@ -31,10 +31,10 @@ macOS, and Linux, see the following links:
3131
For traditional Windows PowerShell workloads, see [Installing Windows PowerShell][install-winps].
3232

3333
> [!IMPORTANT]
34-
> The [Windows PowerShell ISE][ise] is still available for Windows. However, it is no longer in
34+
> The [Windows PowerShell ISE][ise] is still available for Windows. However, it's no longer in
3535
> active feature development. The ISE only works with PowerShell 5.1 and older. As a component of
3636
> Windows, it continues to be officially supported for security and high-priority servicing fixes.
37-
> We have no plans to remove the ISE from Windows.
37+
> we've no plans to remove the ISE from Windows.
3838
3939
## Install VS Code and the PowerShell Extension
4040

@@ -61,8 +61,8 @@ For traditional Windows PowerShell workloads, see [Installing Windows PowerShell
6161
1. After VS Code has reloaded, you're ready for editing.
6262

6363
For example, to create a new file, click **File > New**. To save it, click **File > Save** and then
64-
provide a file name, such as `HelloWorld.ps1`. To close the file, click the `X` next to the file
65-
name. To exit VS Code, **File > Exit**.
64+
provide a filename, such as `HelloWorld.ps1`. To close the file, click the `X` next to the filename.
65+
To exit VS Code, **File > Exit**.
6666

6767
### Installing the PowerShell Extension on Restricted Systems
6868

@@ -82,8 +82,8 @@ Import-Module $HOME\.vscode\extensions\ms-vscode.powershell*\modules\PowerShellE
8282
```
8383

8484
You're prompted with **Do you want to run software from this untrusted publisher?** Type `A` to run
85-
the file. Then, open VS Code and check that the PowerShell extension is functioning properly. If you
86-
still have problems getting started, let us know on [GitHub issues][ghi].
85+
the file. Then, open VS Code and verify that the PowerShell extension is functioning properly. If
86+
you still have problems getting started, let us know in a [GitHub issue][ghi].
8787

8888
### Choosing a version of PowerShell to use with the extension
8989

@@ -157,55 +157,57 @@ You can add other PowerShell executable paths to the session menu through the
157157
[Visual Studio Code setting](https://code.visualstudio.com/docs/getstarted/settings):
158158
`powershell.powerShellAdditionalExePaths`.
159159

160-
Add an item to the list `powershell.powerShellAdditionalExePaths` or create the list if it doesn't
161-
exist in your `settings.json`:
160+
You can do this using the GUI:
162161

163-
```json
164-
{
165-
// other settings...
162+
1. From the **Command Palette** search for and select **Open User Settings**. Or use the
163+
keyboard shortcut on Windows or Linux <kbd>Ctrl</kbd>+<kbd>,</kbd>. On macOS, use
164+
<kbd>Cmd</kbd>+<kbd>,</kbd>.
165+
1. In the **Settings** editor, search for **PowerShell Additional Exe Paths**.
166+
1. Click **Add Item**.
167+
1. For the **Key** (under **Item**), provide your choice of name for this additional PowerShell
168+
installation.
169+
1. For the **Value** (under **Value**), provide the absolute path to the executable itself.
170+
171+
You can add as many additional paths as you like. The added items show up in the session menu with
172+
the given key as the name.
166173

167-
"powershell.powerShellAdditionalExePaths": [
168-
{
169-
"exePath": "C:\\Users\\tyler\\Downloads\\PowerShell\\pwsh.exe",
170-
"versionName": "Downloaded PowerShell"
171-
}
172-
],
174+
Alternatively you can add key-value pairs to the object
175+
`powershell.powerShellAdditionalExePaths` in your `settings.json`:
173176

174-
// other settings...
177+
```json
178+
{
179+
"powershell.powerShellAdditionalExePaths": {
180+
"Downloaded PowerShell": "C:/Users/username/Downloads/PowerShell/pwsh.exe",
181+
"Built PowerShell": "C:/Users/username/src/PowerShell/src/powershell-win-core/bin/Debug/net6.0/win7-x64/publish/pwsh.exe"
182+
},
175183
}
176184
```
177185

178-
Each item must have:
179-
180-
- `exePath`: The path to the `pwsh` or `powershell` executable.
181-
- `versionName`: The text that will show up in the session menu.
186+
> [!NOTE]
187+
> Prior to version 2022.5.0 of the extension, this setting was a list of objects with the required
188+
> keys `exePath` and `versionName`. A breaking change was introduced to support configuration via
189+
> GUI. If you had previously configured this setting, please convert it the new format. The value
190+
> given for `versionName` is now the **Key**, and the value given for `exePath` is now the
191+
> **Value**. You can do this more easily by resetting the value and using the Settings interface.
182192
183193
To set the default PowerShell version, set the value `powershell.powerShellDefaultVersion` to the
184-
text displayed in the session menu (also known as the `versionName`):
194+
text displayed in the session menu (the text used for the key):
185195

186196
```json
187197
{
188-
// other settings...
189-
190-
"powershell.powerShellAdditionalExePaths": [
191-
{
192-
"exePath": "C:\\Users\\tyler\\Downloads\\PowerShell\\pwsh.exe",
193-
"versionName": "Downloaded PowerShell"
194-
}
195-
],
196-
198+
"powershell.powerShellAdditionalExePaths": {
199+
"Downloaded PowerShell": "C:/Users/username/Downloads/PowerShell/pwsh.exe",
200+
},
197201
"powershell.powerShellDefaultVersion": "Downloaded PowerShell",
198-
199-
// other settings...
200202
}
201203
```
202204

203205
After you've configured this setting, restart VS Code or to reload the current VS Code window from
204206
the **Command Palette**, type `Developer: Reload Window`.
205207

206-
If you open the session menu, you now see your additional PowerShell versions!
208+
If you open the session menu, you now see your additional PowerShell installations.
207209

208-
> [!NOTE]
210+
> [!TIP]
209211
> If you build PowerShell from source, this is a great way to test out your local build of
210212
> PowerShell.
211213
@@ -220,7 +222,7 @@ contains the PowerShell script.
220222
1. Set a breakpoint - select a line then press <kbd>F9</kbd>
221223
1. Press <kbd>F5</kbd> to start debugging
222224

223-
You should see the Debug actions pane appear which allows you to break into the debugger, step,
225+
You should see the Debug actions pane appear that allows you to break into the debugger, step,
224226
resume, and stop debugging.
225227

226228
### Workspace debugging
@@ -283,7 +285,7 @@ configurations. One useful configuration to add is **PowerShell: Launch Script**
283285
configuration, you can specify a file containing optional arguments that are used whenever you press
284286
<kbd>F5</kbd> no matter which file is active in the editor.
285287

286-
After the debug configuration is established, you can select which configuration you want to use
288+
After the debug configuration is established, you can select the configuration you want to use
287289
during a debug session. Select a configuration from the debug configuration drop-down in the
288290
**Debug** view's toolbar.
289291

0 commit comments

Comments
 (0)