-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Task Provider Sample shows no tasks #1019
Comments
Fixed with this code still don't understand where my mistake was. /*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
export class TaskProvider implements vscode.TaskProvider {
static esp_tool_task_type = 'esp_tool_tasks';
private tasks: vscode.Task[] | undefined;
// We use a CustomExecution task when state needs to be shared across runs of the task or when
// the task requires use of some VS Code API to run.
// If you don't need to share state between runs and if you don't need to execute VS Code API in your task,
// then a simple ShellExecution or ProcessExecution should be enough.
// Since our build has this shared state, the CustomExecution is used below.
constructor(private workspaceRoot: string) { }
public async provideTasks(): Promise<vscode.Task[]> {
return this.getTasks();
}
public resolveTask(_task: vscode.Task): vscode.Task | undefined {
return this.getTask(_task.definition);
}
private getTasks(): vscode.Task[] {
if (this.tasks !== undefined) {
return this.tasks;
}
this.tasks = [];
this.tasks.push(this.getTask({type:TaskProvider.esp_tool_task_type}));
return this.tasks;
}
private getTask(definition: any): vscode.Task {
if (definition === undefined) {
definition = {type: TaskProvider.esp_tool_task_type};
}
const execution = new vscode.ShellExecution("echo \"Hello World\"");
const problemMatchers = ["$myProblemMatcher"];
return (new vscode.Task(definition, vscode.TaskScope.Workspace,
"Build", "myExtension", execution, problemMatchers));
}
} |
Hey @kenkit could you share a working project with the sample? I tried to get it working today but was unable to. Things "work" (compiles, runs, activates, etc), except it always says I also looked at the task provider hello world sample on SO you linked to and found more questions of the same nature. |
Note that you need a non-empty Rakefile to test this, because it's creating a task per item in the file. The sample code works for me with VS Code 1.94 and the following Rakefile:
You can then start VS Code with this extension, and cmd-shift-p 'Tasks: Run Task' offers 'rake'. |
Thx @Wilfred - I've put this in the cooler for a while, since using the command API works for my purposes currently. |
Extension sample
task-provider-sample
VS Code version
1.89
What went wrong?
I have tried using the task provider sample but I have not managed to get it to list any tasks.
I even tried a sample I found here which uses the same api but it also doesn't show anything. Upon debugging I can see that the methods for retrieving tasks are called and they do return tasks.
This is the other example I tried from SO
The text was updated successfully, but these errors were encountered: