最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - visual studio code clean task - Stack Overflow

programmeradmin2浏览0评论

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?

Share asked Jun 21, 2017 at 8:42 IliaIlia 3411 gold badge3 silver badges13 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 2

After 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.

发布评论

评论列表(0)

  1. 暂无评论