microsoft / vscode

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

Unable to run independent task from tasks.json #27151

Closed BillDenton closed 7 years ago

BillDenton commented 7 years ago
Extension Author Version
language-x86-64-assembly 13xforever 2.2.9
rainbow-brackets 2gua 0.0.6
read-only-indicator alefragnani 0.6.0
alignment annsk 0.3.0
Doxygen bbenoist 1.0.0
vscode-astyle chiehyu 0.6.2
python donjayamanne 0.6.4
EditorConfig EditorConfig 0.9.3
matlab Gimly81 0.5.0
triggertaskonsave Gruntfuggly 0.1.2
status-bar-tasks GuardRex 0.2.0
vscode-dimmer hoovercj 2.1.0
docthis joelday 0.4.4
center-editor-window kaiwood 2.0.2
select-part-of-word mlewand 1.0.1
cpptools ms-vscode 0.11.1
indent-rainbow oderwat 0.6.1
vscode-clearcase OpenNingia 1.9.2
vscode-icons robertohuertasm 7.7.0
theme-cyanicpastels SamuelLampa 0.0.9
indenticator SirTori 0.4.2
vscode-hexdump slevesque 1.3.0
code-spell-checker streetsidesoftware 1.1.0
comment-snippets Tobiah 0.2.0
selectline-statusbar tomoki1207 0.0.2
dark-plus-material vangware 1.0.2
change-case wmaurer 1.0.0
highlight-trailing-white-spaces ybaumes 0.0.2 ;

Steps to Reproduce:

  1. Configure a task in tasks.json that starts an internal program. e.g. a command prompt.
  2. Run the task.
  3. Run another task. Can't run another task because the first task hasn't finished. I would like a method to run an external task which is detached from the VS Code, ie it will not be monitored by VS Code. I have a lot of tools which run independently with their own GUI and it would be good to start them from with VS Code because they related to the code being edited.
dbaeumer commented 7 years ago

This is already available in the new task runner. Raise the version of the tasks.json to 2.0.0.

I will close the issue although the terminal runner is not the default yet. But there are no plans to add parallel task support to the output based task runner.

BillDenton commented 7 years ago

Changed to: "version": "2.0.0", How do I run a independent task? Where's the documentation for 2.0.0

dbaeumer commented 7 years ago

@BillDenton in the works since it is not the default yet. Basic documentation is in the release notes of the previous releases.

BillDenton commented 7 years ago

I couldn't find anything applicable in the release notes. Using the information in http://stackoverflow.com/questions/41105361/how-to-run-background-task-in-vs-code-under-windows, the best I've managed so far is:

{
      "taskName": "Notepad",
      "suppressTaskName": true,
      "command": "powershell",
       "args": [ "(New-Object -ComObject WScript.Shell).Run('notepad', 1, $false)" ]
}

Note: My actual tasks are more complex as they use the current filename and other parameters. This was just for testing. This runs independently so I can launch other tasks (including more of these) immediately. It prompts to "Press any key to close the terminal", which isn't much use in this case as there isn't anything interesting in the terminal. Obviously for a build task it would be useful to see the terminal.

BillDenton commented 7 years ago

Is is possible to have the terminal automatically close once the task has finished?

dbaeumer commented 7 years ago

Currently not, but there are requests to get better control over this.

BillDenton commented 7 years ago

Do you have issue numbers for those requests?

BillDenton commented 7 years ago

Now, the new task runner is the default, is there a method for launching independent tasks? Or do I still need to use the method above?

dbaeumer commented 7 years ago

Yes, you can now run n tasks in parallel.

BillDenton commented 7 years ago

To summarise my understanding: Different tasks (as named by "taskName" in tasks.json) can run in separate terminals. I was trying to run task which is external to VS Code so it isn't monitored for completion, another instance of the same task could be run and would continue running after VS Code exits (and doesn't block exit). I have succeeded in doing this by: { "taskName": "Example", "group": "none", "type": "shell", "problemMatcher": [], "presentation": { "echo": true, "reveal": "never", "focus": false, "panel": "dedicated" }, "options": { "cwd": "${workspaceRoot}\example" }, "command": "", "args": [ "start \"\" python example.pyw" ] },

Another question: Is it possible to group tasks so that common parameters don't have to be repeated for each task.

dbaeumer commented 7 years ago

@BillDenton there is currently no support to group tasks. Feel free to open a feature request.

BillDenton commented 7 years ago

Raised defect #30636 for support of grouping tasks.