Skip to content

Automatically run build_runner on VS Code startup, not working #1516

Closed

Description

@HerrNiklasRaab

An issue for a problem, which came up in this issue: #1211 (comment)

Here is my project: intersect.zip

@DanTup Yes, at least sort of.

I wanted to start the watch task as soon as I open VS Code. So I did the following:

  1. STRG + SHIFT + P
  2. Typed: "Tasks Configure Task" ENTER
  3. Selected, the Task I wanted to configure
  4. Modified generated task.json to the following (only added "runOptions"):

image

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.

Similar to this one:
dart-lang/build#1025 (comment)

Any idea?

Activity

  1. HerrNiklasRaab commented on Mar 8, 2019

    @HerrNiklasRaab
    Author

    After the VS Code February 2018 update, this doesn't appear anymore.

  2. DanTup commented on Mar 8, 2019

    @DanTup
    Member

    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).

  3. HerrNiklasRaab commented on Mar 8, 2019

    @HerrNiklasRaab
    Author

    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.

  4. reopened this on Mar 8, 2019
  5. DanTup commented on Mar 8, 2019

    @DanTup
    Member

    Are you able to attach the smallest possible folder you can repro it with?

  6. DanTup commented on Mar 11, 2019

    @DanTup
    Member

    @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?

  7. added
    awaiting infoRequires more information from the customer to progress
    on Mar 11, 2019
  8. HerrNiklasRaab commented on Mar 11, 2019

    @HerrNiklasRaab
    Author

    Sadly it doesn't work. I tried the following:

    • Set dart.previewBuildRunnerTasks: true only in User Settings
    • Set dart.previewBuildRunnerTasks: true only in Workspace Settings
    • Set dart.previewBuildRunnerTasks: true in both Settings

    Anything else that I can try?

  9. DanTup commented on Mar 11, 2019

    @DanTup
    Member

    @HerrNiklasRaab Two things to check:

    1. Any errors/warnings in the dev console (Help -> Toggle Developer Tools)
    2. 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.

  10. HerrNiklasRaab commented on Mar 11, 2019

    @HerrNiklasRaab
    Author

    Hey @DanTup,

    1. No Errors in Console
    2. 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.

  11. DanTup commented on Mar 11, 2019

    @DanTup
    Member

    @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)

  12. HerrNiklasRaab commented on Mar 11, 2019

    @HerrNiklasRaab
    Author

    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

    I opened a dart file, and then I restarted VS Code, but I get the same error.

    Could you try to open my project without any tabs or files open, while restarting?

  13. DanTup commented on Mar 11, 2019

    @DanTup
    Member

    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?

  14. 19 remaining items

  15. removed this from the Backlog milestone on Nov 12, 2020
  16. DanTup commented on Dec 8, 2021

    @DanTup
    Member

    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.

  17. reopened this on Dec 8, 2021
  18. added
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    and removed on Dec 8, 2021
  19. added this to the v3.30.0 milestone on Dec 8, 2021
  20. added
    in tasksRelates to VS Code tasks, such as those provided by Task Providers
    on Dec 8, 2021
  21. modified the milestones: v3.30.0, v3.31.0 on Dec 8, 2021
  22. modified the milestones: v3.34.0, v3.36.0 on Jan 20, 2022
  23. added a commit that references this issue on Sep 2, 2025
    a730528
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in tasksRelates to VS Code tasks, such as those provided by Task Providersis enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions