-
Notifications
You must be signed in to change notification settings - Fork 481
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
Add TaskProvider implementation for dynamic task generation #787
Comments
@daviwil I have a question related to Invoke-Build. There is a tool New-VSCodeTask.ps1 This is doable and not that difficult. But I wonder if such a tool is needed at NB
|
Hey Roman! Yep, I definitely know about it. I haven't used it because I'm pretty comfortable editing the tasks.json file. I'll give it a try though! You may not need to maintain that script much longer if the PowerShell extension will be able to get the list of tasks on its own. Does the output encoding issue still exist with the new 2.0.0 version of the task runner that uses the Integrated Terminal? In theory it will use powershell.exe's default encoding, so whatever works there should work fine in the new task runner's output. Quick thought on how I'll make this feature work: I'm thinking that at first I'll look for build scripts in the typical default file names for psake and Invoke-Build: FolderName.build.ps1, build.ps1, .build.ps1, psake.ps1, etc in the root workspace folder. I'll also provide a workspace-level setting where you can configure the path to the build script to override that behavior. Once I have the build script path, I'll parse the file and look for top-level function invocations that call I'm also thinking about providing a $psEditor API so that module authors can arbitrarily add tasks, but that will come a little later :) |
@nightroman In addition to the encoding issue see microsoft/vscode#15179 (comment). Adding tasks to an existing tasks.json is a pain. And you do need to be able to add to existing tasks.json files. I frequently have my own custom tasks defined so modifications need to be additive. Frankly I was hoping they would go with a file-based approach e.g.: psmodule-tasks.json, gulp-tasks.json, etc. With the API approach, I'm not sure yet how this helps Plaster when run outside the context of VSCode. Even in the context of VSCode we'll need to wire up Plaster with this API somehow. Maybe we pass $psEditor into Plaster? |
I think the new API allows you to do exactly what you would hope for: making your own file-based approach. An extension could add a task provider that can pull tasks from any file type containing tasks (MSBuild, PowerShell build scripts, Gulp, etc). I believe this should work in addition to the existing tasks.json file. As far as Plaster plugging into this is concerned, when Plaster starts to provide the "project model" for module projects, it will hook into PSES to provide a list of tasks that can be run in VS Code. Either Plaster can be the place where the task-sourcing behavior comes from or it could override a simple built-in implementation that works even when Plaster isn't present. |
I think so. Unless I am using a different version or do something not quite right. How can I check?
Perhaps much more that 90%. Yet I have some doubts on guessing about the default For Invoke-Build the proper way would be ### How to get task names
# change to the workspace root
Set-Location -LiteralPath $env:VSCODE_CWD
# get tasks as IB sees them
$tasks = Invoke-Build ??
# task names
$tasks.Keys
### How to invoke
# change to the workspace root
Set-Location -LiteralPath $env:VSCODE_CWD
# invoke
Invoke-Build $taskName Note that IB finds the default build script in both cases. |
I agree with every sentence. I was planning to support this in New-VSCodeTask.ps1, Frankly, the integrated console alone made New-VSCodeTask.ps1 somewhat obsolete. |
@nightroman In a tasks.json file, set the Thanks for the example on getting Invoke-Build tasks! You're right, just parsing the build script won't be good enough. I'm trying to avoid the need for module-specific task gathering code but I think there just might not be a way around it. |
@daviwil I tried |
I definitely meant |
Ah, at first I tried 2.0.0, it failed to start, so I thought it was a typo. I tried again, this time I also changed the format of tasks.json (to be like There is one difference though, not sure if it is important or not. task test {
[Console]::OutputEncoding.CodePage
"йцукен"
} When I run it as VSCode task:
When I run it in the integrated console:
So "йцукен" is printed fine in cases (this is good). But the console |
FWIW, I have updated New-VSCodeTask. It uses the terminal 2.0.0, it does not need the work around output encoding, |
Looks like the default codepage in PowerShell is set to the one that's used by default on your system. For the Integrated Console I'm setting it to UTF-8 on purpose to avoid some issues that users have seen with characters in their language. I don't think there's anything to worry about there. Thanks for updating your script, i'll have to give it a try! |
In the upcoming 1.13.0 release, VS Code will be getting a new "task provider" API which will allow us to automatically populate the "Task: Run Task" menu with a task list that we generate from code. This would be really useful for scooping the task names out of a psake or Invoke-Build script so that the user can run them easily.
There isn't any documentation yet but the API shape is here:
https://github.com/Microsoft/vscode/blob/447622435ae4745a0a4b9b7033e178d399c82b88/src/vs/vscode.d.ts#L3804
The text was updated successfully, but these errors were encountered: