Why do we have two configurations to setup the build environment in Visual Studio Code? What is the difference between them?
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.
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.
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 .
The launch. json file is located in a . vscode folder in your workspace (project root folder).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With