I've been trying to use VSCode's tasks.json settings to automate the compiling process of my code. When I run the task I get an infinite loading loop, no errors are shown just the loading symbol and nothing happens.
{
"version": "2.0.0",
"tasks": [
{
"label": "MSVC Build",
"type": "shell",
"options": {
"shell": {
"executable": "C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/Tools/LaunchDevCmd.bat"
}
},
"command": "cl {$file} user32.lib && del *.obj"
}
]
}
I've tried to compile different files in case my code was wrong, the results remain the same, here's an example.
#include <iostream>
using namespace std;
int y = 6;
int x = 4;
int main(){
cout << y x;
}
Since there are no error messages there's nothing that can point me to the problem.
This is what the console is displaying
It stalls before running the command and I have no idea why.
CodePudding user response:
"executable": "C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/Tools/LaunchDevCmd.bat"
This above launches cmd.exe in the terminal of Visual Studio Code. Since LaunchDevCmd.bat
never finishes, the queued command cl {$file} user32.lib && del *.obj
does not run, until you enter exit
in the running cmd.exe inside the terminal.
You definitely wanted
"executable": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvars64.bat"
Or any other .bat file in C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build
. It will not run a new cmd.exe, it will run directly in the terminal of Visual Studio Code.