-
-
Notifications
You must be signed in to change notification settings - Fork 11
Predefined task customization
- Сustomize the Default Build Task
- Create Multiple Tasks
- Customize preLaunchTask
- Create Multiple Launch Cnfigurations
To customize the default build task, preform the following steps:
-
In the VSCode, open command palette (
ctrl + shift + P
on Windows/Linux,command + shift + P
on MacOS). -
In the opened panel, type in the
Configure Default Build Task
: -
Select
dotnet-meteor: Build
from the list:This will add the
tasks.json
file to your project:{ "version": "2.0.0", "tasks": [ { "type": "dotnet-meteor.task", "target": "Build", "problemMatcher": [], "label": "dotnet-meteor: Build", "group": { "kind": "build", "isDefault": true } } ] }
-
Specify a custom pre-build parameter in the
args
section of thetasks.json
file."type": "dotnet-meteor.task", "target": "Build", "problemMatcher": [], "label": "dotnet-meteor: Build", "args": [ "-p:MyCustomBuildOption=value" ], "group": { "kind": "build", "isDefault": true }
You can also change the
target
property value toPublish
. In this case, before running the application,dotnet
will run thepublish
command instead of thebuild
. It is similar to the Visual Studio'sPublish
build configuration.
You can duplicate the default build task and change any of the task setting. The following code snippet contains the default and custom publish tasks:
{
"version": "2.0.0",
"tasks": [
{ //Default build task
"type": "dotnet-meteor.task",
"target": "Build",
"problemMatcher": [],
"label": "dotnet-meteor: Build",
"group": {
"kind": "build",
"isDefault": true
}
},
{ //Custom publish task
"type": "dotnet-meteor.task",
"target": "Publish",
"problemMatcher": [],
"args": [ "-p:MyReleaseProperty=value" ],
"label": "Custom publish task"
}
]
}
To run the custom build task, type in the Run Task
in the VSCode command palette, and choose the task:
-
Create the launch.json file. The following code sample contains its default content:
{ "version": "0.2.0", "configurations": [ { "name": ".NET Meteor Debugger", "type": "dotnet-meteor.debugger", "request": "launch", "preLaunchTask": "dotnet-meteor: Build" } ] }
-
You can set the
preLaunchTask
's value to your task's name. The following code sample defines a new task in thetasks.json
file:{ "version": "2.0.0", "tasks": [ { "type": "dotnet-meteor.task", "target": "Build", "problemMatcher": [], "label": "My custom task", "args": [ "-p:MyCustomProperty=value" ], } ] }
-
Now you can register this task in the
launsh.json
file to run it before the application startup:{ "version": "0.2.0", "configurations": [ { "name": ".NET Meteor Debugger", "type": "dotnet-meteor.debugger", "request": "launch", "preLaunchTask": "My custom task" } ] }
-
Optional step. You can remove the
preLaunchTask
parameter and build the project only when you call the build command:{ "version": "0.2.0", "configurations": [ { "name": ".NET Meteor Debugger", "type": "dotnet-meteor.debugger", "request": "launch" } ] }
You can lanch multiple launch configurations for different run scenarios:
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Meteor (no build)",
"type": "dotnet-meteor.debugger",
"request": "launch"
},
{
"name": ".NET Meteor (custom build)",
"type": "dotnet-meteor.debugger",
"request": "launch",
"preLaunchTask": "My custom task"
},
{
"name": ".NET Meteor (pair to Mac)",
"type": "dotnet-meteor.debugger",
"request": "launch",
"preLaunchTask": "My custom task 2"
}
]
}
Open the side bar's Run and debug
tab and select a launch configuration from the drop-down list: