Combining Visual Studio Code Building Tasks

The Visual Studio documentation contains an example task.json configuration that allows typescript compilation or label compilation. He does not specify how to achieve at the same time.

How can I do that?

Here is a summary of two examples ...

Typescript Example

If I want VSCode to execute the typescript build step, the instructions say that I need to install typescript ( npm install -g typescript ) and then define the following task:

 { "version": "0.1.0", "command": "tsc", "isShellCommand": true, "showOutput": "silent", "args": ["*.ts"], "problemMatcher": "$tsc" } 

Evasion example

If I want VSCode to perform the Markdown build step, the documentation says that I can install the default plugin (e.g. npm install -g marked ) and then define the task:

 { "version": "0.1.0", "command": "marked", "isShellCommand": true, "args": ["sample.md", "-o", "sample.html"] } 

Now what?

Obviously, task.json can contain exactly one JSON object. Thus, I cannot just append both definitions above with a comma. On the other hand, in defining a general task, several tasks can be defined:

 { "version": "0.1.0", "command": "<what goes here?>", "isShellCommand": true, "suppressTaskName": true, //or false? "tasks": [ { "taskName": "Launch Typescript" }, { "taskName": "Launch Markdown" } ] } 

The above skeleton is legal syntax, but it is unclear how to complete the story. I know a discussion here and there about how to solve these problems, but there seems to be a fundamental disconnect. For example, how does VSCode know that it should perform both tasks when I press ctrl+shift+b ?

Of course, VSCode developers have a more direct and easier way to solve several build tasks. Does anyone know what it is?

+5
source share
1 answer

You are almost on the right answer.

You can define several build tasks, as shown in the last example.

What you do not understand is that you can override global properties inside a task. In one task, you can define "command" and "args" in one direction, and in the other with completely different values.

In a sense, copy the meat from the two examples above to each task in its last example

0
source

Source: https://habr.com/ru/post/1242929/


All Articles