Is there a way to execute an ssh
command when debugging a project with .vscode/launch.json
?
For example: ssh -i xxxxx
.
Or is it possible to create a command that you can run from the F1 command palette pop-up? Something like RunCustomCommandxx
.
vscode folder in your workspace (project root folder) or in your user settings or workspace settings. To create a launch. json file, click the create a launch. json file link in the Run start view.
To create a launch. json file, click the create a launch. json file link in the Run start view. Once that's created, it should now be available under your workspace's .
1) Open your project directory/folder in Explorer (windows) or Finder (Mac). 2) Go to bin/Debug/netcoreapp{version}/{projectName}. dll and make sure you copy the absolute and complete path of the main project DLL and put it as a value to all program elements inside your launch. json .
You can define a task in your tasks.json
file and specify that as the preLaunchTask
in your launch.json
and the task will be executed before debugging begins.
Example:
In tasks.json:
For version 0.1.0:
{ "version": "0.1.0", "tasks": [{ "taskName": "echotest", "command": "echo", // Could be any other shell command "args": ["test"], "isShellCommand": true }] }
For version 2.0.0 (newer and recommended):
{ "version": "2.0.0", "tasks": [{ "label": "echotest", "command": "echo", // Could be any other shell command "args": ["test"], "type": "shell" }] }
In launch.json:
{ "configurations": [ { // ... "preLaunchTask": "echotest", // The name of the task defined above // ... } ] }
Tasks documentation: https://code.visualstudio.com/docs/editor/tasks
Launch configuration: https://code.visualstudio.com/docs/editor/debugging#_launch-configurations
The format changed. Visual Studio Code can create the tasks.json
file for you. Inside your launch.json
file and inside any configurations object, just define preLaunchTask
to force auto-creation of the tasks.json
template file:
{ "version": "0.2.0", "configurations": [ { "type": "node", "request": "launch", "name": "launch program", "skipFiles": [ "<node_internals>/**"], "preLaunchTask": "myShellCommand", "program": "${workspaceFolder}/test.js" } ] }
If you do not have file tasks.json
configured:
Your tasks.json
template file will then be created for you. Add your command to command
and the name you put in preLaunchTask
to label
:
{ "version": "2.0.0", "tasks": [ { "label": "myShellCommand", "type": "shell", "command": "echo goodfood" } ] }
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