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
{{ message }}
Repository navigation
Automatically run build_runner on VS Code startup, not working #1516
I wanted to start the watch task as soon as I open VS Code. So I did the following:
STRG + SHIFT + P
Typed: "Tasks Configure Task" ENTER
Selected, the Task I wanted to configure
Modified generated task.json to the following (only added "runOptions"):
Now there is a warning:
Incorrect type. Expected "object".
And when I restart Visual Studio I get an error notification and following output:
Error: The pub task detection didn't contribute a task for the following configuration:
{
"type": "pub",
"command": "watch",
"problemMatcher": [
"dart-pub-build_runner"
],
"runOptions": {
"runOn": "folderOpen"
}
}
The task will be ignored.
VS Code 1.32 has some another serious bug though - see #1518. I would recommend staying on v1.31 until a fix is released (they have a fix, and I've verified from source, but it hasn't been released).
I then tried to uninstall this beta release and install the stable release again. But this didn't help either.
I have really no idea, what causes this problem. But after the VS Code update, I restarted VS Code several times, because I couldn't believe, that the update fixed this. And it worked every time.
If you need anything else to reproduce this, I am here to help.
@HerrNiklasRaab I can reproduce your issue, but if I add "dart.previewBuildRunnerTasks": true to the .code-workspace file and reload, then it goes away. Can you double-check that you have this set correctly somewhere?
Any errors/warnings in the dev console (Help -> Toggle Developer Tools)
If you open a .dart file, then restart/reload, does the error go away? I'm wondering if it happens when the task is found before the extension is activated (or if maybe there's a race there)
For some reason, for me, it only found the task (and prompted to enable auto-running) when I first tried to run it, which means the extension had already had plenty of time to load.
I opened a dart file, and then I restarted VS Code, but I get the same error.
For some reason, for me, it only found the task (and prompted to enable auto-running) when I first tried to run it, which means the extension had already had plenty of time to load.
About this, I am not 100% sure what you meant and if I should check and try to confirm this behaviour.
@HerrNiklasRaab I mean, it didn't pop up to say "Hey, this project has auto-start tasks, do you want to let them run?" until I invoked the "Run Task" command (it didn't find the task automatically at startup).
I approved the auto-run but still I can't reproduce the behaviour 🤔
Oh, hangon... If you change type: "pub" to type: "flutter" and reload, does it work?
(you shouldn't need to do that, but let me know if that fixes it, and I can improve it here)
I did that, but it still runs them. I even collapsed all of the folders in explorer. It seems to always activate the extension (I can see "No devices" in the status bar) despite that.
When you see this issue (eg. no dart files open), do you see "No devices" in the status bar and Dart listed if you run the "Show running extensions" command?
Also - you're testing by opening dev.code-workspace, right? Are you on v1.31 or v1.32 of VS Code?
Activity
HerrNiklasRaab commentedon Mar 8, 2019
After the VS Code February 2018 update, this doesn't appear anymore.
DanTup commentedon Mar 8, 2019
VS Code 1.32 has some another serious bug though - see #1518. I would recommend staying on v1.31 until a fix is released (they have a fix, and I've verified from source, but it hasn't been released).
HerrNiklasRaab commentedon Mar 8, 2019
Ok sorry to disturb again, but after I installed this release: https://github.com/Dart-Code/Dart-Code/releases/tag/v2.23.0-beta.2
The error came back.
I then tried to uninstall this beta release and install the stable release again. But this didn't help either.
I have really no idea, what causes this problem. But after the VS Code update, I restarted VS Code several times, because I couldn't believe, that the update fixed this. And it worked every time.
If you need anything else to reproduce this, I am here to help.
DanTup commentedon Mar 8, 2019
Are you able to attach the smallest possible folder you can repro it with?
HerrNiklasRaab commentedon Mar 8, 2019
https://github.com/Dart-Code/Dart-Code/files/2942880/intersect.zip
DanTup commentedon Mar 11, 2019
@HerrNiklasRaab I can reproduce your issue, but if I add
"dart.previewBuildRunnerTasks": trueto the.code-workspacefile and reload, then it goes away. Can you double-check that you have this set correctly somewhere?HerrNiklasRaab commentedon Mar 11, 2019
Sadly it doesn't work. I tried the following:
dart.previewBuildRunnerTasks: trueonly in User Settingsdart.previewBuildRunnerTasks: trueonly in Workspace Settingsdart.previewBuildRunnerTasks: truein both SettingsAnything else that I can try?
DanTup commentedon Mar 11, 2019
@HerrNiklasRaab Two things to check:
For some reason, for me, it only found the task (and prompted to enable auto-running) when I first tried to run it, which means the extension had already had plenty of time to load.
HerrNiklasRaab commentedon Mar 11, 2019
Hey @DanTup,
About this, I am not 100% sure what you meant and if I should check and try to confirm this behaviour.
DanTup commentedon Mar 11, 2019
@HerrNiklasRaab I mean, it didn't pop up to say "Hey, this project has auto-start tasks, do you want to let them run?" until I invoked the "Run Task" command (it didn't find the task automatically at startup).
I approved the auto-run but still I can't reproduce the behaviour 🤔
Oh, hangon... If you change
type: "pub"totype: "flutter"and reload, does it work?(you shouldn't need to do that, but let me know if that fixes it, and I can improve it here)
HerrNiklasRaab commentedon Mar 11, 2019
Ok, I have news. Only when the a .dart file is open and active (the tab of the .dart file is active) the tasks are starting without any error.
To the result below of my previous post I got, because I opened a .dart file and switched to another tab
Could you try to open my project without any tabs or files open, while restarting?
DanTup commentedon Mar 11, 2019
I did that, but it still runs them. I even collapsed all of the folders in explorer. It seems to always activate the extension (I can see "No devices" in the status bar) despite that.
When you see this issue (eg. no dart files open), do you see "No devices" in the status bar and Dart listed if you run the "Show running extensions" command?
Also - you're testing by opening dev.code-workspace, right? Are you on v1.31 or v1.32 of VS Code?
19 remaining items
DanTup commentedon Dec 8, 2021
I think between a fix made in microsoft/vscode#70303 and microsoft/vscode#126238, this should be fixable now, though requires us to adopt the new
onTaskType:activation event.Ensure extension activates on Dart/Flutter task executions