How to add Visual Studio Developer Prompt as a terminal shell for Visual Studio Code

Viewed 18

In VS Code you can open an terminal in an specific shell.
Instead of just Powershell, i wanted to start up in the Visual Studio Developer Powershell session.

1 Answers

Open the settings of VS Code in json format

This is what I arrived at after some research and playing around with the startup argemunts to get it exactly as I want.
(PS: I left out other profiles for clarity!)

    "terminal.integrated.profiles.windows": {
    "Visual Studio  Professional 2022 Powershell": {
        "path": "pwsh.exe",
        "args": [
            "-noexit",
            "-nologo",
            "-c",
            "&{$cur = gi .;Import-Module \"C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\Common7\\Tools\\Microsoft.VisualStudio.DevShell.dll\"; Enter-VsDevShell c9012106;set-location $cur;}"
        ],
        "icon": "terminal-powershell"
    }
},
"terminal.integrated.defaultProfile.windows": "Visual Studio Professional 2022 Powershell",

'path' is short because pwsh.exe is located via $PATH environment variable

Note that I had to split the command flag and command text in separate arguments.
It doesn't work as one string, although in regular shell this works of course.

The most elaborate part is the lauching of the Visual Studio shell.
I took the information from the installed shortcut you get after installation of VS2022.
I added an small bit to make sure we stay on the current working folder too!

Related