Task
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Run tests",
"type": "shell",
"command": "./scripts/test.sh",
"windows": {
"command": ".\\scripts\\test.cmd"
},
"group": "test",
"presentation": {
"reveal": "always",
"panel": "new"
}
}
]
}
- label: The task's label used in the user interface.
- 任务名
- type: The task's type. For a custom task, this can either be
shell
orprocess
. Ifshell
is specified, the command is interpreted as a shell command (for example: bash, cmd, or PowerShell). Ifprocess
is specified, the command is interpreted as a process to execute. - 任务类型,是shell命令还是二进制文件执行命令
- command: The actual command to execute.
- 执行命令
- args:参数
- windows: Any Windows specific properties. Will be used instead of the default properties when the command is executed on the Windows operating system.
- windows操作系统的指定属性
- group: Defines to which group the task belongs. In the example, it belongs to the
test
group. Tasks that belong to the test group can be executed by running Run Test Task from the Command Palette. - 定义任务所属组,可以同过命令板运行指定组,来运行该组所属的所有任务
- presentation: Defines how the task output is handled in the user interface. In this example, the Integrated Terminal showing the output is
always
revealed and anew
terminal is created on every task run. - 定义如何处理任务中的输出
reveal
控制是否将终端弹出- always
- never
slient
只有扫描到errors warnings
才弹出终端focus
终端是否获取焦点,默认为false
echo
是否输出执行命令到终端,默认为true
showReuseMessage
是否显示“Terminal will be reused by tasks, press any key to close it”这个消息panel
控制终端是否在任务间共享shared
用同一个终端dedicated
同一个任务用同一个终端,该终端其它任务不能使用new
总是创建一个新的终端clear
是否在执行任务前清空终端,默认为false
group
是否在任务执行时通过分割窗口来指定一个终端组
- options: Override the defaults for
cwd
(current working directory),env
(environment variables), orshell
(default shell). Options can be set per task but also globally or per platform. Environment variables configured here can only be referenced from within your task script or process and will not be resolved if they are part of your args, command, or other task attributes. - options可以为每个任务单独设置,也可以全局设置,或者对每个平台进行设置
cwd
定义任务运行的当前目录env
环境变量- Environment variables configured here can only be referenced from within your task script or process and will not be resolved if they are part of your args, command, or other task attributes.
- 当前定义的环境变量只能在你的任务或者程序中引用
- 如果他们是你参数、命令或者任务属性的一部分,则不会被解析(???)
shell
修改shell
- runOptions: Defines when and how a task is run.
reevaluateOnRerun
控制变量在执行Rerun Last Task时是否重新计算,默认为true
runOn
任务什么时候执行default
默认执行Run Task时候执行folderOpen
在包含的文件夹被打开时执行
- dependsOn:对其它任务的依赖
- dependsOrder:
sequence
按顺序执行dependsOn
- Key:绑定快捷键
变量引用
command, args, and options
只在这三个选项中生效变量引用
预定义变量 Predefined variables
- ${workspaceFolder} - the path of the folder opened in VS Code
- 当前VSCdoe打开的工作目录路径
- ${workspaceFolderBasename} - the name of the folder opened in VS Code without any slashes (/)
- 当前VSCode打开的工作目录名
- ${file} - the current opened file
- 当前打开(编辑)的文件
- ${fileWorkspaceFolder} - the current opened file's workspace folder
- 当前打开文件的所属工作目录
- ${relativeFile} - the current opened file relative to
workspaceFolder
- 当前打开文件的相对路径
- ${relativeFileDirname} - the current opened file's dirname relative to
workspaceFolder
- 当前打开文件的所在文件夹的相对路径
- ${fileBasename} - the current opened file's basename
- 当前打开文件的文件名
- ${fileBasenameNoExtension} - the current opened file's basename with no file extension
- 没后缀扩展的文件名
- ${fileDirname} - the current opened file's dirname
- 打开文件的所在目录的完整路径
- ${fileExtname} - the current opened file's extension
- 打开文件的后缀
- ${cwd} - the task runner's current working directory on startup
- 任务运行的工作目录
- ${lineNumber} - the current selected line number in the active file
- 当前焦点所在的文件行数
- ${selectedText} - the current selected text in the active file
- 当前所选的文本
- ${execPath} - the path to the running VS Code executable
- VSCode执行路径
- ${defaultBuildTask} - the name of the default build task
- 默认的构建任务名称
- ${pathSeparator} - the character used by the operating system to separate components in file paths
- 操作系统分隔路径用的分割符号
- / on macOS or linux, \ on Windows
引用VSCode配置的变量
${config:Name}
例子:
${config:editor.fontSize}
命令变量
${command:commandID}
输入变量
{
"version": "2.0.0",
"tasks": [
{
"label": "task name",
"command": "${input:variableID}"
// ...
}
],
"inputs": [
{
"id": "variableID",
"type": "type of input variable"
// type specific configuration attributes
}
]
}
${input:variableID}
lanuch.json
每个lanuch配置都需要有的属性:
type
- 每个内置调试插件都会引入一种类型:go php cppdbg python
request
- 请求类型lanuch attach
。文档
name
- 配置命名
对所有配置的可选属性
presentation
- 用于下拉框的排序,方便快速检索order
,group
, andhidden
preLaunchTask
- 提前执行tasks.json
中的任务,可以用${defaultBuildTask}
执行默认的任务
postDebugTask
- 结束的时候执行tasks.json
中的任务
internalConsoleOptions
- 控制台的可见性选项
debugServer
- 调试插件开发的时候用
serverReadyAction
- 在输出特定信息时打开指定url
多数调试器支持如下属性
program
- executable or file to run when launching the debugger
args
- arguments passed to the program to debug
env
- environment variables (the valuenull
can be used to "undefine" a variable)
envFile
- path to dotenv file with environment variables
cwd
- current working directory for finding dependencies and other files
port
- port when attaching to a running process
stopOnEntry
- 程序执行后立刻打断点
console
- what kind of console to use, for example,internalConsole
,integratedTerminal
, orexternalTerminal
Loading Comments...