Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is something wrong with my tasks.json settings?

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

This is what the console is displaying

It stalls before running the command and I have no idea why.

>Solution :

"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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading