Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between launch.json and task.json in visual studio code?

Why do we have two configurations to setup the build environment in Visual Studio Code? What is the difference between them?

like image 795
arjun kr Avatar asked Jan 05 '17 11:01

arjun kr


People also ask

What is launch json in VS Code?

A launch. json file is used to configure the debugger in Visual Studio Code. Visual Studio Code generates a launch. json (under a . vscode folder in your project) with almost all of the required information.

What is task json in VS Code?

The tasks. json example above does not define a new task. It annotates the tsc: build tasks contributed by VS Code's TypeScript extension to be the default build task. You can now execute the TypeScript compiler by pressing Ctrl+Shift+B.

How do I launch json in Visual Studio?

To create a launch. json file, click the create a launch. json file link in the Run start view. If you go back to the File Explorer view (Ctrl+Shift+E), you'll see that VS Code has created a .

Where is launch json Visual Studio Code?

The launch. json file is located in a . vscode folder in your workspace (project root folder).


1 Answers

They are not both used to setup the build configuration.

launch.json is used for to launch an app for debugging. It has settings geared for things like mapping to your workspace source code or defining the Chrome port to use.

To use a configuration from launch.json, you select it on the Debug panel and click the run button.

tasks.json is used to execute anything else you may want, be that source code formatters, bundlers or a SASS compiler.

To use a configuration from tasks.json, you select Run Task from the command list.

Here's an example of how they differ in purpose:

I have an Angular 5 application that connects to a .NET web service.

I have one task configured to run the web service, using a command that fires up IISExpress. I have another task configured to run the Angular app using ng serve, which recompiles the app when files change. I execute these two tasks whenever I reopen VS Code, or when the web service changes.

I have two launch configurations as well: One to launch Chrome and start the debugger, and another to debug a page already loaded in Chrome. These I execute whenever I start a debug session.

like image 173
Cobus Kruger Avatar answered Oct 17 '22 00:10

Cobus Kruger