Vscode-cpptools: Support "Run without debugging"

Created on 3 Nov 2017  路  26Comments  路  Source: microsoft/vscode-cpptools

I'm running VSCode 1.17.02 on Ubuntu 16.04 x64 and cpptools 0.14.

Could you please add information about how to launch an application w/o debugging (CTRL+F5) to the VSCode C++ docs and maybe post a complete tasks.json / launch.json example here? I've read a couple of issues now and can't quite make launching work...
I use make to build my projects. I put

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch",
            "runtimeExecutable": "MYEXECUTABLE",
            "program": "${workspaceRoot}/MYOUTPUT.FILE",
            "preLaunchTask": "Make"
            }
    ]
}

into launch.json. My tasks.json looks like this:

{
    "version": "2.0.0",
    "tasks": [
        {
            "taskName": "Make",
            "type": "shell",
            "command": "make",
            "args": [""],
            "group": "build",
            "presentation": {
                "reveal": "always",
                "panel": "dedicated"
            },
            "problemMatcher": {
                "owner": "cpp",
                "fileLocation": ["relative", "${workspaceRoot}"],
                "pattern": {
                    "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "severity": 4,
                    "message": 5
                }
            }
        }
    ]
}

The binary file is built successfully via CTRL+SHIFT+B, but when launching via CTRL+F5 I get the message "No executable targets are available". I guess vscode does not know what output file make generates...

Feature Request debugger

Most helpful comment

I would also love to see a Launch Without Debugging feature added to vscode.

All 26 comments

Just create another task that runs builds and runs executable :|

And connect that to CTRL+F5 through the key bindings? Might work, but how is it actually meant to be done?! What about my launch.json example? Should that work? Why not? The docs are lacking there imo... :/

No you cannot connect it to CTRL + F5 but you'd be able to run it with CTRL+SHIFT+B if you set it default build task which I've done :)

Thanks for the workaround, but I suspect there must be an actual solution to the problem...

@HorstBaerbel We haven't implemented Launch without Debugging. I'll mark this as a feature request but you may either do it as @agauniyal suggested with a batch file or from the Terminal within VSCode.

Thanks. Will try the "build-and-run" version then for the moment...

I would also love to see a Launch Without Debugging feature added to vscode.

In some cases, you can use Code Runner an alternative.

Isn't CTRL+F5 already the default key binding for _Start (without debugging)_ (workbench.action.debug.run)? ~It seems to work for me out of the box too: F5 launches with debugging, CTRL+F5 launches without.~

EDIT: In my case I don't think debugging is actually ever running properly, but at least CTRL+F5 is still "running without debugging". The only difference I see is that the call stack shows threads when I F5 but not when I CTRL+F5...

Visual Studio Code Default Key Bindings:
https://code.visualstudio.com/docs/getstarted/keybindings#_debug

My _launch.json_ file:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(Windows) Launch",
            "type": "cppvsdbg",
            "request": "launch",
            "program": "${workspaceFolder}/bin/main.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}/data/",
            "environment": [],
            "externalConsole": true,
        }
    ]
}

My _tasks.json_ file:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "type": "shell",
            "command": "g++",
            "args": [
                "-g", "${workspaceFolder}/src/main.cpp", "-o", "${workspaceFolder}/bin/main.exe"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

My version of VS Code:

Version: 1.27.1 (system setup)
Commit: 5944e81f3c46a3938a82c701f96d7a59b074cfdc
Date: 2018-09-06T09:21:18.328Z
Electron: 2.0.7
Chrome: 61.0.3163.100
Node.js: 8.9.3
V8: 6.1.534.41
Architecture: x64

@pieandcakes maybe a week ago, Ctrl+F5 do the same with Start without debugging. Don't why doesn't work now.

@roachsinai We haven't done work enable that scenario and we haven't shipped an extension update since 0.20.1 which shipped a few months back. Did you apply a VS Code update?

Yes, update it at 2019-01-09...

Needing this launch feature.

We need this to run external application and capture the stdout, with no debug attached.

@polyclash @xgdgsc for now you can use the VS Code Terminal window to launch your application from the command line.

@pieandcakes yes, I use a task, the internal terminal is configured with bash(mingw64), but the terminal don't receive the stdout from the application.

But then I have to set environment variables again in the terminal, I already set those in launch configurations.

Looking forward to this feature.

Also waiting for this feature.

One more vote. Setting all environment vars, launch arguments with unit test filters etc again separately is quite annoying.
Debuggers start really slowly in larger projects, due to big symbol tables, being able to make minor edits to code and hit Ctrl+F5 to trigger rebuild and run would really speed iterations.

Another vote. I am writing performance-critical code and I often want to benchmark runtime in release mode. The command line arguments I specify in launch.json are not passed to the command.

+1, I want to reuse args from launch.json. Also enable to start from the terminal.

Is this implemented yet?

+1

@fufjvnvnf No.

+1

Was this page helpful?
0 / 5 - 0 ratings