Open HorstBaerbel opened 6 years ago
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
Has there been any progress on this? This is a very nice feature to have.
My scenario is that I use compounds
to launch client and server executables and debug them both at the same time. Command-line arguments are sometimes long and verbose for configuring various debug environments. For most cases this is great.
However, they both share a lot of the same library code and sometimes I need breakpoints to only trigger for one process and the other process interferes, making debugging slow.
Support for run without debugging with be perfect here.
Meanwhile, I'm using the fact that VSCode currently doesn't debug child processes, creating a forwarding executable that launches the target and exits immediately:
#include <Shlwapi.h>
#include <stdio.h>
#include <windows.h>
#pragma comment(lib, "shlwapi.lib")
int main(int argc, const char* argv[])
{
// Header
printf("Forwarder.exe Running...\n\n");
if (argc < 2)
{
printf("ERROR: Not enough arguments provided\n");
return 1;
}
// Get target executable
const char* executable = argv[1];
printf("Executable to Launch : %s\n", executable);
if (!PathFileExists(executable))
{
printf("ERROR: Executable path doesn't exist\n");
return 1;
}
// Parse command line for forwarding
const char* command_line = GetCommandLine();
printf("Command Line : %s\n", command_line);
const char* arguments = PathGetArgs(command_line);
printf("Forwarder Arguments : %s\n", arguments);
const char* forward_arguments = PathGetArgs(arguments);
printf("Arguments to forward : %s\n\n", forward_arguments);
// Launch and forward, exiting immediately
STARTUPINFO si{};
si.cb = sizeof(si);
PROCESS_INFORMATION pi{};
if (CreateProcess(executable, (char*)forward_arguments, nullptr, nullptr, FALSE, 0, nullptr, nullptr, &si, &pi) == FALSE)
{
printf("ERROR: Failed to create process\n");
return 1;
}
printf("Success\n");
return 0;
}
I would love to be able to delete this :)
I don't get it. VSCode seems so complicated, with these json configurations to launch. Isn't it possible to tell vscode to run some executable when hitting ctrl+f5, without an attached debugger? I can't even figure out how to set up two launch configurations, and tell VSCode to run one for ctrl+f5 and the other for f5.
The makefile tools extension sets up a play and a debug button, but there doesn't seem to be an obvious way to configure these, and to connect them to the f5 and ctrl-f5 shortcuts.
"Run without debugging" not working and also devices are not being listed in VS code while if we write and run command in command line then flutter application is compiled. Its weird with VSCode now, it was working well earlier. any suggestion will be welcomed. Thanks.
same need + 1
I don't get it. VSCode seems so complicated, with these json configurations to launch. Isn't it possible to tell vscode to run some executable when hitting ctrl+f5, without an attached debugger? I can't even figure out how to set up two launch configurations, and tell VSCode to run one for ctrl+f5 and the other for f5.
The makefile tools extension sets up a play and a debug button, but there doesn't seem to be an obvious way to configure these, and to connect them to the f5 and ctrl-f5 shortcuts.
Same boat. -- VS Code has built-in support for F5 = Run with Debugging, and CTRL+F5 for Run without Debugging -- it's kind of an industry standard. -- Why can't it be supported?
Why can't we tie a configuration option to each one? -- I don't get it. -- Why does launch.json
have to be only for debugging, and not just used for all launch configurations, like it's supposed to be?
Why can't we just add a type
? (i.e. cpp
instead of cppdbg
?) -- and then just infer the correct item to run based on whether or not we wanted to be running in debug mode.
@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.
@pieandcakes & @agauniyal Can you explain how set default build task CTRL+SHIFT+B.
still waiting for this in 2022
want it too
bump
In my situation the main issue is that clicking via the menu ("Run Without Debugging Ctrl+F5") works, and often also using the via Ctrl+P using "Tasks: Run Task" followed by choosing the specific task to run, but the hotkey Ctrl+F5 seems completely dead. I am on Linux now, I am not sure about the situation on Windows right now. Currently trying it with a Rust project, but I know that with C# .NET projects and C/C++ I am having the same issues, Ctrl+F5 does nothing.
Bumping up - again - in 2023!
Bumping up again - half a year + 5 days later.
Here is my workaround. Might seem unnecessary, but the goal for me was just to be able to use the "run without debugging" keybinding for my c++ projects as well.
Basically, set up a debug task that exists immediately, but runs a task afterwards. The task (tasks.json) can run arbitrary commands, so here you place your actual build + run code, in my case make.
launch.json
{
"version": "2.0.0",
"configurations": [
{
"name": "start",
"request": "launch",
"type": "node-terminal",
"command": "exit",
"postDebugTask": "build"
},
]
}
tasks.json
{
"version": "2.0.0",
"command": "bash",
"options": {
"cwd": "${workspaceRoot}"
},
"args": [
"-c"
],
"tasks": [
{
"label": "build",
"args": [
"make start"
]
}
]
}
If you want to play with "when" conditions for keybindings, you can skip the first step and just have the task file. Then you would need a keybinding like below, that only runs on c++ files (and then you set the debug keybinding to activate on non cpp-files). I didn't like this approach, however, because I still want to use the launch.json when I am actually debugging (for which I switch the active task in the UI), but it is up to you.
{
"key": "cmd+b",
"command": "workbench.action.tasks.runTask",
"args": "build",
"when": "editorLangId == 'cpp'"
},
So no one knows how this is supposed to work? Great editor... a default key binding and function that isn't workable.
While maybe not exactly what we have in mind, I've made analogous configuration options in task.json
that I have in launch.json
. The configured task.json
options run without the debugger but still has the configurability and ease of use as the launch.json
options. With a name like "launch.json" I figured it would have the option to execute without a debugger, but it seems like launch.json
is only intended for debugging? If so, that seems like a bit of a misnomer to call it that?
Please fix this! +1
[moderated] They never care about C/C++ good stuff. It is 5 years that we are asking for this STUPID feature. It is clear that there is a political reason to NOT support it. Maybe they want us all to download 25 GB of Visual Studio, to compile hello world.
@antoniocaruso Please watch your language, this behavior of yours is disrespectful.
That language is much less disrespectful than https://github.com/microsoft/vscode/issues/204270 https://github.com/microsoft/vscode/issues/204728 https://github.com/microsoft/vscode/issues/203967. .
I can ask to my 250 Engineering student to espress their opinion in how easy and smart is trying to use this extension, to learn C/C++, so maybe they will be less harsh, but ..maybe not. I'm just trying to convey a simple messages to developers:
what is your target?
is this a "community editor"? or it is a "professional developer" editor? DECIDE. At this moment I cannot suggest it, too cumbersome to just do SIMPLE EASY stuff, and I'm harsh because there is large community in Colleges that really like to use ONE EDITOR for all platforms (like this) for teaching, without spending hours to explain to students how to install different development environments.
But if they have to write builds.json, and endless configuration variables, just to setup the path for the compiler and cannot just "build" please, and "run" please, without a debugger, that they never ever know about. Maybe this is 'no way'.
And, this is not the first comment, in several bug reports that raise this problem, but you seems really ..not interested. So, maybe I'll ask the students to install emacs, and solve the problem like in the '80.
There are two different Microsoft teams that contribute to the C++ extension - the C++ language team and the debugger team. The C++ language team (my team) remains very active developing language services for the C++ extension but the debugger team has been focused on other priorities within the company. I know that this isn't what anyone wants to hear as this is one of our top voted feature requests, but we do continue to let them know that this is a priority for us.
Dear bibbrow, thanks for your replay, at least we know that we are not wrong. Just priorities on the other side do not match.
But please, let me say to all of you:
The C++ language team, need to think about a simple issue:
Do you want to have support for Visual Studio for NEW programmers that are actually learning to code, and learning for the first time to install an editor, understand the differences between editors and IDE, use a compiler, etc etc with this language and with C, so we have developers that work in C/C++ in the next 10 years or not?
If you care about THE LANGUAGES (and if you are in a team called 'C++ extension - C++ language' maybe you must care, then, I think that 'language service' like intellisense are USELESS if people are unable to do: 1) Install Visual Studio 2) Unzip mingw 3) Open Visual Studio 4) Install your extension for C/C++ support 5) Create a .c or .cpp file with hello world.
and thaaaa daaaam, the editor ask you 'where is the compiler please?' (no intelligence, just ask), people provide a directory path for all mingw64 and you can just see everything working.
I don't want to iterate on this, and I accept your explanations, it is a big company, but, I hope that if you as Microsoft spent 10 years to figure out how to provide a real terminal to users, and now a good system like WSL, please do not spent 4 years to understand that you have a good product in Visual Studio Code, and you can do something really 'sensible' to a community in school and university by providing them a good simple editor with a good simple build system.
Debugging is not my problem. Compiling with just "gcc name.c -o name" and runnning with "./name" is better, I fixed it with another extension, but still....json to changes, and so on. Maybe people in microsoft do not know about it, but emacs, is able to compile and run a program in .c, with just a keyboard shortcut. and it is 30 year old. It is surprising to me, that you have that increadible beast under your fingers, with typescript, and cannot do something that in lisp has been done 30 years ago.
Hi @antoniocaruso, I'd be happy to chat about priorities and such if you'd like to open a Discussion. This issue probably isn't the right place for that unless it concerns the Run without debugging feature.
I'll address the compilers issue briefly though... as much as we'd like to bundle a compiler with the extension, logistically it doesn't make sense for us:
Instead, we provide installation instructions in our C++ Walkthrough and on linux/macOS we can run the installation commands directly for you. Run the "C/C++: Select IntelliSense Configuration..." command, then pick "Install a compiler". On Windows the option is "Help me install a compiler" which will take you back to the Walkthrough -- perhaps this should be its own command though...
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
into launch.json. My tasks.json looks like this:
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...