I'm working on a project that requires me to compile C++ code using MSVC, but I am working mostly with VSCode. As such, I was wondering if there is a way for me to add the Developer Powershell as an integrated terminal, so that I can compile without needing a secondary terminal open. I thought of just opening VSCode from the Developer PS itself, but since this is mostly a temporary project it seemed like a lot of repetitive work. I tried using the Shell launcher
extension for VSCode but it didn't work. Is there anything I can do?
Update:
- This answer is obsolete. For a current solution, see Dan Fiego's answer, which uses the dedicated
Launch-VsDevShell.ps1.ps1
script that has since been introduced, and shows a JSON object that you can place inside the"terminal.integrated.profiles.windows"
property insettings.json
, which makes a shell namedDeveloper PowerShell for VS 2022
available in the integrated terminal.
To make Visual Studio Code's integrated terminal act like the Developer PowerShell for VS 2019
console that comes with Visual Studio 2019, add the following to your Visual Studio Code settings.json
file (> Preferences: Open Settings (JSON)
):
"terminal.integrated.shell.windows": "C:/Windows/SysWOW64/WindowsPowerShell/v1.0/powershell.exe"
and
"terminal.integrated.shellArgs.windows": "-noe -c Import-Module 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/Tools/Microsoft.VisualStudio.DevShell.dll'; Enter-VsDevShell ed9e071d"
Note that a 32-bit version of PowerShell is started, followed by import of a module and a call to a function from that module.
I've taken (and adapted) the commands - whose details may differ depending on the Visual Studio version - from the Properties dialog of the following shortcut file (*.lnk
):
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2019\Visual Studio Tools\Developer PowerShell for VS 2019.lnk
SysWOW64
with System32
, you'll get a 64-bit PowerShell session - but I can't tell you whether everything will work as intended - do let us know. –
Nadabb I found this in March of 2023, looking for an answer to this question. At this point, Microsoft documents a Launch-VsDevShell.ps1
script that is the recommended way to start a developer PowerShell terminal. I tried simply making that script the path
parameter in the above JSON, but that didn't work. Then I tried making it the sole member of args
, and that seemed to work briefly and then exit. Finally, I added -NoExit
and that seems to work like a charm!
Of note for anyone coming after me, I'm using Visual Studio Community 2022 with an x86-64 install (so it's under C:\Program Files\
.
"Developer PowerShell for VS 2022": {
"source": "PowerShell",
"icon": "terminal-powershell",
"args": [
"-WorkingDirectory",
"${workspaceFolder}",
"-NoExit",
"C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/Tools/Launch-VsDevShell.ps1"
]
}
"-File",
before the path to the .ps1
file for this to work. Also worth mentioning that this snippet is presumably meant to be placed inside the "terminal.integrated.profiles.windows"
property in the settings.json
file. –
Nadabb A variation of the answer of mklement0 is to use terminal.integrated.profiles.windows
in the Visual Studio Code settings.json
like this:
"terminal.integrated.profiles.windows": {
"Developer PowerShell for VS 2019": {
"source": "PowerShell",
"icon": "terminal-powershell",
"path": "{env:windir}\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.exe",
"args": [
"-noe",
"-c",
"&{Import-Module 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/Tools/Microsoft.VisualStudio.DevShell.dll'; Enter-VsDevShell 7068d947}"
]
}
}
Update:
- This answer is obsolete. For a current solution, see Dan Fiego's answer, which uses the dedicated
Launch-VsDevShell.ps1.ps1
script that has since been introduced, and shows a JSON object that you can place inside the"terminal.integrated.profiles.windows"
property insettings.json
, which makes a shell namedDeveloper PowerShell for VS 2022
available in the integrated terminal.
To make Visual Studio Code's integrated terminal act like the Developer PowerShell for VS 2019
console that comes with Visual Studio 2019, add the following to your Visual Studio Code settings.json
file (> Preferences: Open Settings (JSON)
):
"terminal.integrated.shell.windows": "C:/Windows/SysWOW64/WindowsPowerShell/v1.0/powershell.exe"
and
"terminal.integrated.shellArgs.windows": "-noe -c Import-Module 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/Tools/Microsoft.VisualStudio.DevShell.dll'; Enter-VsDevShell ed9e071d"
Note that a 32-bit version of PowerShell is started, followed by import of a module and a call to a function from that module.
I've taken (and adapted) the commands - whose details may differ depending on the Visual Studio version - from the Properties dialog of the following shortcut file (*.lnk
):
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2019\Visual Studio Tools\Developer PowerShell for VS 2019.lnk
SysWOW64
with System32
, you'll get a 64-bit PowerShell session - but I can't tell you whether everything will work as intended - do let us know. –
Nadabb Update for Visual studio 2022 on my machine
"terminal.integrated.profiles.windows": {
"Developer PowerShell for VS 2022": {
"source": "PowerShell",
"icon": "terminal-powershell",
"args": [
"-noe",
"-c",
"&{Import-Module 'C:/Program Files (x86)/Microsoft Visual Studio/2022/Community/Common7/Tools/Microsoft.VisualStudio.DevShell.dll'; Enter-VsDevShell ed9e4c07}"
]
}
}
-WorkingDirectory C:\\Users\\eduar\\path\\to\\repo
as another argument (or two), but then it's hardcoded to that path. I haven't been able to find a way to get it to just automatically go to the workspace folder. –
Eyestrain I had issues with Windows style paths on my machine and I have only installed Build Tools so the path is changed as well. My settings.json looks like this now:
"Developer PowerShell for VS 2022": {
"overrideName": true,
"source": "PowerShell",
"icon": "terminal-powershell",
"args": [
"-NoExit",
"& \"C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\Common7\\Tools\\Launch-VsDevShell.ps1\"",
]
}
Additionally I had to change the Execution-Policy for PS scripts:
Set-ExecutionPolicy -ExecutionPolicy Bypass
Execute in Admin Powershell at your own risk.
Expanding on all answers here to make it behave a little more as expected. Add this to your settings.json:
"terminal.integrated.profiles.windows": {
"Developer PowerShell for VS 2022": {
"overrideName": true,
"source": "PowerShell",
"icon": "terminal-powershell",
"args": [
"-WorkingDirectory",
"${workspaceFolder}",
"-NoExit",
"C:/Program Files/Microsoft Visual Studio/2022/Professional/Common7/Tools/Launch-VsDevShell.ps1",
"-SkipAutomaticLocation"
]
}
},
The -WorkingFolder ${workspaceFolder}
and SkipAutomaticLocation
will make the terminal start in your current workspace.
The "overrideName": true
will override the default pwsh
name in the list of terminals once it's opened and name it Developer PowerShell for VS 2022
:
I couldn't find a way to dynamically get the Visual Studio installation directory unfortunately so everyone will have to put in their absolute path.
vswhere.exe
help find it? –
Typify -SkipAutomaticLocation
seems to cause an error –
Matronize Tried existing answers, not works perfectly.
My working config is the following, which navigate to current working directory (the root directory that VSCode opens):
"terminal.integrated.profiles.windows": {
"Developer PowerShell for VS 2022": {
"overrideName": true,
"source": "PowerShell",
"icon": "terminal-powershell",
"args": [
"-NoExit",
"& \"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\Common7\\Tools\\Launch-VsDevShell.ps1\"",
"-SkipAutomaticLocation"
]
}
},
© 2022 - 2025 — McMap. All rights reserved.