microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.09k stars 29.25k forks source link

Add support for running custom tasks in VS Code Web #157112

Open thegecko opened 2 years ago

thegecko commented 2 years ago

We have a web extension which provides a custom task provider and works as expected in both VS Code Desktop and VS Code Web.

A minor issue with dependencies was found in https://github.com/microsoft/vscode/issues/157041 but this was closed as tasks aren't officially supported in VS Code Web.

I can understand that shell and process tasks can't work without some sort of access to the user's machine, but can custom tasks be officially supported especially as they already seem to work very well for us?

This would include exposing the task menu items and making it clear only custom tasks will work.

alexr00 commented 2 years ago

Custom execution tasks should work in web. They aren't officially supported because we haven't found a real world use case for them yet, but a fair amount of work went into getting them most of the way there. The original thinking was that maybe an extension could contribute some CI-like tasks which would give users a way to build and test without actually having a way to run anything locally.

It sounds like you have a real world use for custom execution tasks in the web though and that it mostly works for you (with the exception of dependsOn, which would be a bug).

As for exposing all the task menu items: maybe this could be done if we detect an extension that contributes custom execution tasks. We don't currently have a great way to do this without fetching tasks from the extensions, which an be expensive, but if we just look at the tasks in tasks.json this might be a reasonable approach.

thegecko commented 2 years ago

It sounds like you have a real world use for custom execution tasks in the web though...

We actually have two ;) One is a remote build system and the other is a deployment task for flashing binaries on microcontrollers. These work today and I'm happy to share more detail if it helps move this feature forwards.

...and that it mostly works for you (with the exception of dependsOn, which would be a bug).

That's right.

As for exposing all the task menu items: maybe this could be done if we detect an extension that contributes custom execution tasks. We don't currently have a great way to do this without fetching tasks from the extensions, which an be expensive, but if we just look at the tasks in tasks.json this might be a reasonable approach.

This sounds like an excellent approach and is so close to working today. Could activation events be used as a hint to triggering such a scan?

thegecko commented 1 month ago

A further update on this as we are still seeing issues with custom task providers in vscode.dev.

I've created an example extension to showcase the issues: https://github.com/thegecko/task-provider-sample

This is derived from the official example, but stripped back to be just the custom task.

Running this on the desktop, the tasks picker is populated and the custom task can be run.

Screenshot 2024-09-16 at 21 44 22

Running this on vscode.dev, the task menu does nothing:

Screenshot 2024-09-16 at 21 46 52

There's no error in the console and the behaviour is the same with and without a workspace open.