use*_*947 18 visual-studio-code
我想知道当一个带.vscode/launch.json的项目建立时,是否有一种方法来命令一个ssh命令?像"ssh -i xxxxx"之类的东西
或者是否可以创建一个可以从F1弹出窗口运行的命令,RunCustomCommandxx
Sar*_*ana 27
您可以在文件中定义一个任务,tasks.json并在调试开始之前将其指定为preLaunchTask您launch.json的任务和任务.
例:
在tasks.json中:
对于0.1.0版:
{
"version": "0.1.0",
"tasks": [{
"taskName": "echotest",
"command": "echo", // Could be any other shell command
"args": ["test"],
"isShellCommand": true
}]
}
Run Code Online (Sandbox Code Playgroud)
对于2.0.0版(更新和推荐):
{
"version": "2.0.0",
"tasks": [{
"label": "echotest",
"command": "echo", // Could be any other shell command
"args": ["test"],
"type": "shell"
}]
}
Run Code Online (Sandbox Code Playgroud)
在launch.json中:
{
"configurations": [
{
// ...
"preLaunchTask": "echotest", // The name of the task defined above
// ...
}
]
}
Run Code Online (Sandbox Code Playgroud)
任务文档:https://code.visualstudio.com/docs/editor/tasks
启动配置:https://code.visualstudio.com/docs/editor/debugging#_launch-configurations
Emm*_*N K 17
格式变了。Visual Studio Code 可以tasks.json为您创建文件。在您的launch.json文件和任何配置对象内,只需定义preLaunchTask以强制自动创建tasks.json模板文件:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "launch program",
"skipFiles": [ "<node_internals>/**"],
"preLaunchTask": "myShellCommand",
"program": "${workspaceFolder}/test.js"
}
]
}
Run Code Online (Sandbox Code Playgroud)
如果您没有tasks.json配置文件:
你的tasks.json模板文件将您创建。您的命令添加到command你放在名字preLaunchTask来label:
{
"version": "2.0.0",
"tasks": [
{
"label": "myShellCommand",
"type": "shell",
"command": "echo goodfood"
}
]
}
Run Code Online (Sandbox Code Playgroud)
Yau*_*nka 10
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch app",
"program": "lib/main.dart",
"request": "launch",
"type": "dart"
},
{
"name": "Build an APK Release",
"command": "flutter build apk --release",
"request": "launch",
"type": "node-terminal"
},
{
"name": "Install an APK on a device",
"command": "flutter install",
"request": "launch",
"type": "node-terminal"
}
]
}
Run Code Online (Sandbox Code Playgroud)
对我来说,我只需要一个环境变量,这是不同的。您不需要为此执行任务,因为(至少对我而言)它在启动器运行时不起作用。
多亏了这里,我让它在我的启动器 (launch.json) 条目中像这样工作:
"environment": [{
"name": "ENVIRONMENT_VARIABLE_NAME",
"value": "${workspaceFolder}/lib" //Set to whatever value you want.
}],
Run Code Online (Sandbox Code Playgroud)
是的,这是可能的。只需使用:
"type": "node-terminal"
Run Code Online (Sandbox Code Playgroud)
(不用担心它会显示“ node -terminal”,它应该可以在 VS Code 中开箱即用)
并在“command”属性中指定您的命令:
"command": "ssh -i xxxx"
Run Code Online (Sandbox Code Playgroud)
希望能帮助到你。
| 归档时间: |
|
| 查看次数: |
15007 次 |
| 最近记录: |