Skip to content

launch.json preLaunchTask #2086

Closed
Closed

Description

@Spown

I have several issues with it:

  1. it appears that it at least partially ignores the configuration of the named task in the tasks.json. For example, if I have a task watch:scss with "showOutput": "never" there - running it manually doesn't invoke new tab with output, but if I also add it to launch.json via "preLaunchTask": "watch:scss" - it opens output every time I re/launch the app. However it seems that it does respect the isWatching flag, since it doesn't start the app until I terminate the task manually if the setting is false/omitted or it does start the app if the setting is set to true.
  2. if the task is a persistent one ("isWatching": true) relaunching the app prompts me to terminate the already running one. And it doesn't start the app right away if I chose to terminate it in the prompt - I need to run it again. Which is annoying as hell as you can imagine. There should be an additional setting for either silently restarting the preLaunchTask or silently skip the task launch and assuming that the already running should run until the end of the current session. And/or there should be a default based on the either - in any case prompting is not an option.
  3. preLaunchTask is hardly present in the documentation at all. I think many more people would complain if they just knew that this option even exist...

thanks in advance.

Activity

  1. added
    feature-request
    debug
    on Jan 18, 2016
  2. isidorn commented on Feb 5, 2016

    @isidorn

    Thanks for the detailed feedback.

    1. It seems like taskService.run does not respect configuration specified in tasks.json Dirk Bäumer (@dbaeumer)
    2. There has already been some issues regarding this. I personally am not a big fan of that terminate promp. Dirk Bäumer (@dbaeumer) can comment more
    3. I see preLaunchTask being mentioned in https://code.visualstudio.com/docs/editor/debugging, though not to a great extenent. Also preLaucnhTask is present in auto completion in launch.json. To increase discoverability I added preLaunchTask: '' to the initally generated launch.json

    Since issues 1. and 2. are in the task world forwarding this to Dirk Bäumer (@dbaeumer)

  3. added
    tasks
    and removed
    debug
    on Feb 5, 2016
  4. changed the title [-]lounch.json preLaunchTask[/-] [+]launch.json preLaunchTask[/+] on Feb 11, 2016
  5. dbaeumer commented on Feb 11, 2016

    @dbaeumer
    Member

    Isidor Nikolic (@isidorn)

    1. I do :-). As Spown pointed out everything works when he runs the task directly. Could it be that the debugger brings the output channel to front to inform about problems with the prelaunch task.
    2. I don't see what the task runner framework should do. IMO the debugger framework should do the following: for non watching task wait for the promise to finish. For watching tasks don't start if promise is not finish and listen to task events to see if the task is currently active or not. If needed I can add API to differenciate better between watchind and non watching tasks
  6. added
    debug
    and removed
    tasks
    on Feb 11, 2016
  7. 5 remaining items

  8. Spown commented on Mar 9, 2016

    @Spown
    Author

    I appreciate the work and staff, but I fail to see how is the "new" mechanic regarding the watching task is different from the one before (original post/subissue 2.)? I get slightly different warning but I still get it. The point was not to be bugged while relaunching. But I still get the prompt[terminate|close] -> regardless of the choice the launch won't occur until the next launch initiated by the user. Thats still 3 actions instead of one.

  9. Spown commented on Mar 9, 2016

    @Spown
    Author

    And if i take isWatching flag away - It starts the task and nothing happens. I need to hit F5 again for the launch to occur. Actually without isWatching it works more like it should - since every subsequent relaunch doesn't invoke any prompts. The task is still a watching one, since it keeps running, and VSCode assumes it should continue running. I'm confused.

  10. isidorn commented on Mar 9, 2016

    @isidorn

    Thanks for coming back with more feedback. Is your last comment captured in bug #3669?
    For the previous comment - regarding subissue 2, I can not reproduce this. So I have a watch task, I start debugging again and you get prompted? I do not see this. Can you please create a new issue if you see this on latest vscode (0.10.10) with reproducable steps - it would be great if you could share your repo.

    Thanks

  11. daslicht commented on Mar 29, 2016

    @daslicht

    How does the task.json need to look if you want to call it as PreLaunchTask?

    I tried it like this, but it fails :

    "preLaunchTask": "mytask",
    
    {
        "version": "0.1.0",
        "command": "tsc",
        "isShellCommand": true,
        "showOutput": "silent",
        "args": [""],
        "problemMatcher": "$tsc",
    
        "tasks": [
            {
                "taskName": "mytask",
                "args": [],
                "isBuildCommand": true,
                "problemMatcher": "$tsc"
            }
        ]
    }
    
    Warning: global matchers and tasks can't be mixed. Ignoring global matchers.
    error TS6053: File '.ts' not found.
    error TS6053: File 'mytask.ts' not found.
    
  12. dbaeumer commented on Mar 29, 2016

    @dbaeumer
    Member

    If you only have one global task you can use the command name as a prelaunch task name.

    {
        "version": "0.1.0",
        "command": "tsc",
        "isShellCommand": true,
        "showOutput": "silent",
        "args": [""],
        "problemMatcher": "$tsc"
    }
    
    "preLaunchTask": "tsc"
  13. daslicht commented on Mar 29, 2016

    @daslicht

    OK I tried now :

    {
        "version": "0.2.0",
        "configurations": [
            {
                "name": "Debug Node",
                "type": "node",
                "request": "launch",
                "program": "${workspaceRoot}/app.js",
                "stopOnEntry": false,
                "args": [],
                "cwd": "${workspaceRoot}/.",
                "runtimeExecutable": null,
                "runtimeArgs": [
                    "--nolazy"
                ],
                "env": {
                    "NODE_ENV": "development"
                },
                "externalConsole": false,
                "preLaunchTask": "tsc",
                "sourceMaps": true,
                "outDir": null
            },
            {
                "name": "Attach",
                "type": "node",
                "request": "attach",
                "port": 5858
            }
        ]
    }
    
    {
        "version": "0.1.0",
        "command": "tsc",
        "isShellCommand": true,
        "showOutput": "silent",
        "args": [""],
        "problemMatcher": "$tsc"
    }
    
    

    But I get :

    The preLaunchTask 'tsc' terminated with exit code 2.
    
  14. dbaeumer commented on Mar 29, 2016

    @dbaeumer
    Member

    Do you have a tsconfig.json. Then your args need to look like ["-p", "."]

  15. daslicht commented on Mar 29, 2016

    @daslicht

    Yes I have the following tsconfig:

    {
        "compilerOptions": {
            "target": "es5",
            "module": "commonjs",
            "sourceMap": true,
            "allowJs": true
        },
       "exclude": [
            "node_modules",
            "typings"
        ]
    }
    

    When I change the args in my tasks.json or launch json to:

     "args": ["-p","."],
    

    I get :

    Errors detected while running the preLaunchTask 'tsc'.
    
  16. dbaeumer commented on Mar 29, 2016

    @dbaeumer
    Member

    Marc Wensauer (@daslicht) is your repository public somewhere. Then I have a look there.

  17. daslicht commented on Mar 30, 2016

    @daslicht

    Nope, not yet but I can push it, until that which files would you else need to look at else then above ?
    Thank You !

  18. dbaeumer commented on Mar 31, 2016

    @dbaeumer
    Member

    Hard to say. Most of the time it is a file layout thing as well. Can you try another thing. Can you run the tasks by pressing Ctrl+Shift+B and then show the output of the Task (Shift+Ctrl+U) and attach it here.

  19. daslicht commented on Mar 31, 2016

    @daslicht

    SOLVED !:
    I never thought that warning could make the pretask fail.

    I had such warning:

    daslicht:radio1 daslicht$ tsc 
    typings/main/ambient/bluebird/index.d.ts(21,13): error TS2300: Duplicate identifier 'Promise'.
    typings/main/ambient/bluebird/index.d.ts(358,11): error TS2300: Duplicate identifier 'Promise'.
    typings/main/ambient/bluebird/index.d.ts(670,19): error TS2300: Duplicate identifier 'Promise'.
    typings/main/ambient/es6-promise/index.d.ts(14,15): error TS2300: Duplicate identifier 'Promise'.
    typings/main/ambient/es6-promise/index.d.ts(45,16): error TS2300: Duplicate identifier 'Promise'.
    

    After removing bluebird and all its dependencies the task is running !

    💃

    Thank you !

  20. ipanardian commented on Jan 11, 2017

    @ipanardian

    It works! Thanks

    tasks.json

    {
        "version": "0.1.0",
        "command": "tsc",
        "isShellCommand": true,
        "args": ["-p", "."],
        "showOutput": "silent",
        "problemMatcher": "$tsc"
    }
    

    launch.json

    {
        "version": "0.2.0",
        "configurations": [
            {
                "type": "node",
                "request": "launch",
                "name": "Launch Program",
                "program": "${file}",
                "cwd": "${workspaceRoot}",
                "sourceMaps": true,
                "outFiles": ["${workspaceRoot}/out/*.js"],
                "preLaunchTask": "tsc"
            },
            {
                "type": "node",
                "request": "attach",
                "name": "Attach to Process",
                "port": 5858,
                "outFiles": [],
                "sourceMaps": true
            }
        ]
    }
    
  21. locked and limited conversation to collaborators on Nov 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

debugfeature-requestverification-foundverified

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions