Reputation: 489
This trick seems very simple but I don't know how to set up,
What I did :
Go to Archive > Preferences > User Config.
and in the right panel I wrote this...
{
"terminal.integrated.shell.windows":
"C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\Common7\\Tools\\VsDevCmd.bat"
}
works until suddenly disappears.
Thinking about a launch.json
script just for the sake of not writing on the console and using a play button, I know cl
is for calling the compiler but don't know how to deal with the parameters. Someone suggested to use Cmake.
All I want is to run scratch code with the VC/C++ compiler (not limited to the 2017 version, could be any) so any solution will be highly appreciated.
Upvotes: 10
Views: 8117
Reputation: 1
How to set the default integrated terminal in Visual Studio Code 2022
to Developer Powershell
Developer Powershell for VS 2022
For a quick fix using powershell instead of cmd, I added something like this to my settings.json.
"terminal.integrated.profiles.windows" :
{
"Developer Powershell": {
"path": [
"C:\\Windows\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.exe",
],
"args": [
"-Nologo",
"-noe",
"Import-Module C:\\\"Program Files (x86)\"\\\"Microsoft Visual Studio\"\\2022\\BuildTools\\Common7\\Tools\\Microsoft.VisualStudio.DevShell.dll;",
"Enter-VsDevShell fb4ff659"
],
"icon": "terminal-powershell"
}
},
"terminal.integrated.defaultProfile.windows": "Developer Powershell"
Make sure to change the path and Enter-VsDevShell ########
to fit your system by looking at the target of Developer Powershell for VS 2022
in shortcut properties.
Developer Powershell for VS 2022 > Open file location > Properties > Target
*Works on Windows 10 Pro (19045.4894)
and VS code 2022 (1.93.1)
Upvotes: 0
Reputation: 198
VS Code 1.73.1 and Visual Studio 2022 Developer Command Prompt v17.4.1 as of Nov 2022
go to with Windows Run
to edit VS Code setting json
%APPDATA%\Code\User\settings.json
Add this inside { } of "terminal.integrated.profiles.windows"
"Developer Powershell": {
"path": [
"${env:windir}\\Sysnative\\cmd.exe",
"${env:windir}\\System32\\cmd.exe"
],
"args": [
"/k",
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\Common7\\Tools\\VsDevCmd.bat"
],
"icon": "terminal-powershell"
}
Upvotes: 2
Reputation: 2455
While the other answers are still valid, note that the current (Nov. 2021) way of doing this is to use the terminal-profiles; the other mentioned methods have been deprecated.
"terminal.integrated.profiles.windows": {
"Command Prompt": {
"path": [
"${env:windir}\\Sysnative\\cmd.exe",
"${env:windir}\\System32\\cmd.exe"
],
"args": [
"/K",
"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\Common7\\Tools\\VsDevCmd.bat",
],
"icon": "terminal-cmd"
}
}
Upvotes: 4
Reputation: 100
Just updating the @K0j0 answer :)
Here is for Microsoft Visual Studio 2017 Community.
{
// New shell with Developer Command Prompt
"terminal.integrated.shell.windows": "C:\\Windows\\Sysnative\\cmd.exe",
"terminal.integrated.shellArgs.windows": ["/k", "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\Common7\\Tools\\VsDevCmd.bat"]
}
Upvotes: 4
Reputation: 5257
Luiz's response mentions the 32bit command prompt. The following are the settings for the 64bit Visual Studio 2017 Developer command prompt:
"terminal.integrated.shell.windows": "C:\\Windows\\Sysnative\\cmd.exe",
"terminal.integrated.shellArgs.windows": [
"/k",
"C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Auxiliary\\Build\\vcvars64.bat"
],
Upvotes: 2
Reputation: 99
Try this
{
"terminal.integrated.shell.windows": "C:\\Windows\\Sysnative\\cmd.exe",
"terminal.integrated.shellArgs.windows": ["/k", "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\Tools\\VsDevCmd.bat"]
}
Seems like you you need to use cmd as the shell but pass in /k and the batch script that sets the proper environment variables for the dev command prompt.
Btw, my command prompt is for Visual Studio 2015, you'll want to update yours for your version which looks like 2017.
Upvotes: 3