How to run a command in Visual Studio Code with launch.json

前端 未结 4 2084
刺人心
刺人心 2020-12-03 00:38

Is there a way to execute an ssh command when debugging a project with .vscode/launch.json?

For example: ssh -i xxxxx.

O

4条回答
  •  盖世英雄少女心
    2020-12-03 01:02

    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": [ "/**"],
            "preLaunchTask": "myShellCommand",
            "program": "${workspaceFolder}/test.js"
          }
      ]
    }
    

    If you do not have file tasks.json configured:

    • launch the debugger. Visual Studio Code will inform you: "could not find the task myShellCommand"
    • select Configure TaskCreate tasks.json file from templateOthers

    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"
        }
      ]
    }
    

提交回复
热议问题