I am debugging my CPP code with VSCode. I need to use a preLaunchTask to set my environment before my code run. So my code should run after preLaunchTask right in the same terminal. But it start in two different terminal now. How can I do with this?
And btw how can I start the process in the same terminal next time? Some process will start another terminal next time, I am confuse.
My preLaunchTask:
{
"label": "source_setup",
"type": "shell",
"command": "source ./devel/setup.zsh && export ROS_MASTER_URI=http://localhost:11311/ "
},
preLaunchTask - to launch a task before the start of a debug session, set this attribute to the label of a task specified in tasks. json (in the workspace's . vscode folder). Or, this can be set to ${defaultBuildTask} to use your default build task.
A launch. json file is used to configure the debugger in Visual Studio Code. Visual Studio Code generates a launch. json (under a . vscode folder in your project) with almost all of the required information.
The launch. json file is located in a . vscode folder in your workspace (project root folder).
Switch to the Run and Debug view (Ctrl+Shift+D) and select the create a launch. json file link. VS Code will let you select an "debugger" in order to create a default launch configuration. Pick "Mock Debug".
As stated by @isidorn in this vscode GitHub issue this feature is currently not yet supported. In the meantime, people can achieve the desired behaviour by adding the following code to their .bashrc
# Source ros setup.bash if present
if [ -f '../devel/setup.bash' ]; then . "../devel/setup.bash";fi
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With