Just a small profile template to get the Visual Studio Developer command prompt environment, but in PowerShell, but in the Windows Terminal. Cake on cake 🍰
Add the following profile to your Windows Terminal profiles.json
file.
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"profiles": [
{
"guid": "{dd241469-5e90-55ff-816c-914203bdc6ea}",
"name": "Dev Cmd Prompt VS 2019",
"commandline": "powershell.exe -noe -c \".{$vsInstallPath=&\"\"\"${Env:ProgramFiles(x86)}\\Microsoft Visual Studio\\Installer\\vswhere.exe\"\"\" -Property InstallationPath;Import-Module \"\"\"$vsInstallPath\\Common7\\Tools\\Microsoft.VisualStudio.DevShell.dll\"\"\";function prompt(){Write-Host \"\"\"VS Dev Prompt $Env:VSCMD_VER \"\"\" -NoNewline -ForegroundColor White;Write-Host $(pwd) -NoNewline;Write-Host \"\"\">\"\"\" -NoNewline -ForegroundColor White;return \"\"\" \"\"\"}Enter-VsDevShell -VsInstallPath $vsInstallPath -SkipAutomaticLocation}\"",
"hidden": false,
"startingDirectory": ".",
"acrylicOpacity" : 0.75,
"useAcrylic" : true
}
]
}
What's nice about the new format is that you can supply default values, such as "useAcrylic": true
for all profiles.
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"profiles": {
"defaults": {
},
"list": [
{
"guid": "{dd241469-5e90-55ff-816c-914203bdc6ea}",
"name": "Dev Cmd Prompt VS 2019",
"commandline": "powershell.exe -noe -c \".{$vsInstallPath=&\"\"\"${Env:ProgramFiles(x86)}\\Microsoft Visual Studio\\Installer\\vswhere.exe\"\"\" -Property InstallationPath;Import-Module \"\"\"$vsInstallPath\\Common7\\Tools\\Microsoft.VisualStudio.DevShell.dll\"\"\";function prompt(){Write-Host \"\"\"VS Dev Prompt $Env:VSCMD_VER \"\"\" -NoNewline -ForegroundColor White;Write-Host $(pwd) -NoNewline;Write-Host \"\"\">\"\"\" -NoNewline -ForegroundColor White;return \"\"\" \"\"\"}Enter-VsDevShell -VsInstallPath $vsInstallPath -SkipAutomaticLocation}\"",
"hidden": false,
"startingDirectory": ".",
"acrylicOpacity" : 0.75,
"useAcrylic" : true
}
]
}
}
The commandLine
property in the profile holds the following script wrapped inside a powershell.exe -noe -c
call:
.{
$vsInstallPath = &"${Env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -Property InstallationPath
Import-Module "$vsInstallPath\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
function prompt() {
Write-Host "VS Dev Prompt $Env:VSCMD_VER " -NoNewline -ForegroundColor White
Write-Host $(pwd) -NoNewline
Write-Host ">" -NoNewline -ForegroundColor White
return " "
}
Enter-VsDevShell -VsInstallPath $vsInstallPath -SkipAutomaticLocation
}