I'm working in Visual Studio Code in Ubuntu on my Typescript project. And I'm wondering is there any possibility to execute some kind of 'clean
' task.
Here's my tasks.json
{
// See /?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"tasks": [
{
"taskName": "tsc",
"mand": "tsc",
"isShellCommand": true,
"isBackground": true,
"problemMatcher": "$tsc"
},
{
"taskName": "clean",
"linux": {
"mand": "rm",
"args": [
"./src/*.js"
],
"isShellCommand": true
},
"isShellCommand": true,
"isBackground": true
}
]
}
And here's my project structure.
Executing task clean
says there's no such files or directory, while executing 'pwd'
instead of rm
says that I'm in the root of my project.
Any suggestions how does this build system work? Maybe there's some special syntax for env variables in VS Code?
I'm working in Visual Studio Code in Ubuntu on my Typescript project. And I'm wondering is there any possibility to execute some kind of 'clean
' task.
Here's my tasks.json
{
// See https://go.microsoft./fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"tasks": [
{
"taskName": "tsc",
"mand": "tsc",
"isShellCommand": true,
"isBackground": true,
"problemMatcher": "$tsc"
},
{
"taskName": "clean",
"linux": {
"mand": "rm",
"args": [
"./src/*.js"
],
"isShellCommand": true
},
"isShellCommand": true,
"isBackground": true
}
]
}
And here's my project structure.
Executing task clean
says there's no such files or directory, while executing 'pwd'
instead of rm
says that I'm in the root of my project.
Any suggestions how does this build system work? Maybe there's some special syntax for env variables in VS Code?
3 Answers
Reset to default 2After VSCode 1.14, we have a new tasks manager in VSCode. I'm using .NET Core on ubuntu and I have a build
and a clean
tasks like this:
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "process",
"mand": "dotnet",
"args": [
"build",
"MyProj.csproj"
],
"options": {
"cwd": "${workspaceFolder}/src/MyProj/"
},
"problemMatcher": "$msCompile"
},
{
"label": "clean",
"type": "shell",
"linux": {
"mand": "rm",
"args": [
"-rfv",
"bin/*",
"obj/*"
]
},
"windows": {
"mand": "del",
"args": [
"/S /Q",
"bin/*",
"obj/*"
]
},
"options": {
"cwd": "${workspaceFolder}/src/MyProj/"
},
"problemMatcher": []
}
]
}
Both tasks works as expected.
I have also been looking for this, but as far as I understand, it's not possible to have more than one task in tasks.json. You can have a tasks array, but that only contains different mand line parameters for the same task. This example has the 'echo' task, and you can call it with different parameters. If you call the task 'hello' then 'echo Hello World' will be executed:
{
"version": "0.1.0",
"mand": "echo",
"isShellCommand": true,
"args": [],
"showOutput": "always",
"echoCommand": true,
"suppressTaskName": true,
"tasks": [
{
"taskName": "hello",
"args": ["Hello World"]
},
{
"taskName": "bye",
"args": ["Good Bye"]
}
]
}
Have you tried using workspace variables? ${workspaceRoot}
might be particular useful for you.