Using Windows developer CLI tools outside of Visual Studio is way more of a pain than it needs to be. Here's how to set up the VS Developer Command Prompt in VS Code's integrated terminal.
- Visual Studio with any workloads you need
- VS Code
Open up the VS Code settings.json file.
First, create an environment variable with the path of the VS batch script that sets variables. The exact path may vary based on your VS version and desired build architecture.
"terminal.integrated.env.windows": {
"VsDevVars" : "\"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Auxiliary\\Build\\vcvars64.bat\""
},Then create 2 profiles in terminal.integrated.profiles.windows:
"terminal.integrated.profiles.windows": {
"Dev CMD": {
"path": "cmd.exe",
"args": ["/k %VsDevVars%"]
},
"Dev PowerShell": {
"path": "cmd.exe",
"args": ["/k %VsDevVars% && pwsh"]
},These profiles just run the batch script to set all the necessary environment variables in CMD. The "Dev PowerShell" one then launches PowerShell with all the environment variables inherited.
The environment variable is necessary as a workaround for this VS Code bug. Otherwise we could just stick the batch file path directly in the terminal profiles.
Setting up Developer Command Prompt in Windows Terminal is pretty similar:
{
"commandline": "cmd.exe /k \"%PROGRAMFILES(X86)%\\Microsoft Visual Studio\\2019\\Community\\VC\\Auxiliary\\Build\\vcvars64.bat\"",
"guid": "{1748ecca-abdd-4aa4-bcc4-9fca0d045be5}",
"hidden": false,
"icon": "ms-appx:///ProfileIcons/{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.png",
"name": "Dev CMD",
"startingDirectory": "%USERPROFILE%"
},
I haven’t tried this since 2021; it might be out of date sorry