You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the addition of the CustomExecution task type, extensions can now contribute tasks that are run as callbacks from VS Code, instead of tasks that run as a script or a process. Using the below code as a starting point, create an extension that uses the CustomExecution type to contribute tasks. Things to test:
Contribute multiple tasks. Test that they all get executed correctly.
Contribute multiple tasks, and make only some of them have a CustomExecution. The others can have a ShellExecution type. (example: let execution = new vscode.ShellExecution("echo hello");).
Test that you can use the TerminalRenderer from within the CustomExecution to send text to the terminal and to read from the terminal using write and onDidAcceptInput.
Configure a task that has a CustomExecution in tasks.json. Try setting various presentation properties and other properties(dependsOn, label, group, problemMatcher, etc.) and test that they all behave correctly. Add other properties to CustomTestingTaskDefinition and in the package.json and test that the right task is modified when you configure it in tasks.json. How to refer to the task from tasks.json
{
"type": "customTesting",
"customProp1": "testing task one",
// try using dependsOn, presentation, and other task configuration properties
}
Try returning different exit codes from the CustomExecution. 0 is success, anything else is not. Test that when the exit code is non-zero and ”presentation:{ “reveal”:”silent”} that the terminal is shown when the task completes.
Test that the Rerun Last Task command works with CustomExecution tasks.
Try setting a custom task as the preLaunchTask in a launch configuration and test that launch configuration still works.
Test that a ”type”:”shell” task in tasks.json can depend on a contributed CustomExecution task.
To start with this sample code, copy vscode.proposed.d.ts into your extension and add to your package.json:
lettaskProvider: vscode.Disposable|undefined;consttaskType: string="customTesting";exportfunctionactivate(_context: vscode.ExtensionContext): void{letrakePromise: Thenable<vscode.Task[]>|undefined=undefined;taskProvider=vscode.tasks.registerTaskProvider(taskType,{provideTasks: ()=>{rakePromise=getSomeTasks();returnrakePromise;},resolveTask(_task: vscode.Task): vscode.Task|undefined{// Don't worry about testing anything with resolve task. It is old API that was never implemented.returnundefined;}});}exportfunctiondeactivate(): void{if(taskProvider){taskProvider.dispose();}}interfaceCustomTestingTaskDefinitionextendsvscode.TaskDefinition{/** * One of the task properties. This can be used to customize the task in the tasks.json */customProp1: string;}asyncfunctiongetSomeTasks(): Promise<vscode.Task[]>{letresult: vscode.Task[]=[];letkind: CustomTestingTaskDefinition={type: taskType,customProp1: "testing task one"};letexecution=newvscode.CustomExecution((terminalRenderer,cancellationToken,args): Thenable<number>=>{returnnewPromise<number>(resolve=>{// This is the custom task callback!resolve(0);});});consttaskName="First custom task";lettask=newvscode.Task2(kind,vscode.TaskScope.Workspace,taskName,taskType,execution);result.push(task);returnresult;}
The text was updated successfully, but these errors were encountered:
Refs: #66818
Complexity: 4
With the addition of the CustomExecution task type, extensions can now contribute tasks that are run as callbacks from VS Code, instead of tasks that run as a script or a process. Using the below code as a starting point, create an extension that uses the CustomExecution type to contribute tasks. Things to test:
let execution = new vscode.ShellExecution("echo hello");
).write
andonDidAcceptInput
.CustomTestingTaskDefinition
and in the package.json and test that the right task is modified when you configure it in tasks.json. How to refer to the task from tasks.json”presentation:{ “reveal”:”silent”}
that the terminal is shown when the task completes.preLaunchTask
in a launch configuration and test that launch configuration still works.”type”:”shell”
task in tasks.json can depend on a contributed CustomExecution task.To start with this sample code, copy vscode.proposed.d.ts into your extension and add to your package.json:
Sample code:
The text was updated successfully, but these errors were encountered: