我正在 Ubuntu 中使用 Visual Studio Code 处理我的 Typescript 项目。我想知道是否有可能执行某种“clean
”任务。
这是我的 tasks.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"tasks": [
{
"taskName": "tsc",
"command": "tsc",
"isShellCommand": true,
"isBackground": true,
"problemMatcher": "$tsc"
},
{
"taskName": "clean",
"linux": {
"command": "rm",
"args": [
"./src/*.js"
],
"isShellCommand": true
},
"isShellCommand": true,
"isBackground": true
}
]
}
这是我的项目结构。
执行task clean
表示没有这样的文件或目录,而执行'pwd'
而不是rm
表示我处于我的项目的根。
有什么建议吗?这个构建系统如何工作?也许 VS Code 中的环境变量有一些特殊的语法?
最佳答案
在 VSCode 1.14 之后,我们在 VSCode 中有一个新的任务管理器。我在 ubuntu 上使用 .NET Core,并且有一个 build
和一个 clean
任务,如下所示:
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "process",
"command": "dotnet",
"args": [
"build",
"MyProj.csproj"
],
"options": {
"cwd": "${workspaceFolder}/src/MyProj/"
},
"problemMatcher": "$msCompile"
},
{
"label": "clean",
"type": "shell",
"linux": {
"command": "rm",
"args": [
"-rfv",
"bin/*",
"obj/*"
]
},
"windows": {
"command": "del",
"args": [
"/S /Q",
"bin/*",
"obj/*"
]
},
"options": {
"cwd": "${workspaceFolder}/src/MyProj/"
},
"problemMatcher": []
}
]
}
这两项任务都按预期工作。
关于javascript - Visual Studio 代码清理任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44671002/