最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

visual studio code - VSCode tasks that automatically kills all other tasks on invoke - Stack Overflow

programmeradmin8浏览0评论

When using vs.code, I have to use a non-standard compiler, and it's easier to just run it from Makefile. I have it set up as a task in tasks.json. I am trying to make my postDebugTask remain in terminal if there is an error. I am trying to do that with my postDebugTask called run_flash.

BUT, if I re-invoke the build or "run" process, I want to terminate all running tasks. I am trying to do this with my preLaunchTask kill_all_tasks.

If I launch another process, it does not kill the previous process.

Really, what I want is for any time my normal task is launched, I want to kill off the previous task. Like is there any sort of task option to say "there can only be one of these tasks"?

Here is the launch configuration from my launch.json

        {
            "name": "Compile and Flash",
            "type": "node",
            "request": "launch",
            "internalConsoleOptions": "neverOpen",
            "preLaunchTask" : "kill_all_tasks",
            "postDebugTask": "run_flash",
            "presentation": {
                "hidden": false,
                "group": "terminaloutput",
                "order": 1
            },
            "runtimeExecutable": "echo"
        }

Here are my tasks:

        {
            "type": "shell",
            "label": "run_flash",
            "command": "make clean closechlink; make flash",
            "presentation": {
                "echo": true,
                "focus": true,
                "group": "build",
                "panel": "shared",
                "close": true,
                "reveal": "always",
                "showReuseMessage": true
            },
            "isBackground": false,
            "options": {
                "cwd": "${workspaceFolder}",
            },
            "runOptions": {
                "instanceLimit": 1,
            },
            "group": "build",
            "problemMatcher": { // 
                "owner": "cpp",
                "fileLocation": [
                    "relative",
                    "${workspaceFolder}"
                ],
                "pattern": {
                    "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "severity": 4,
                    "message": 5
                },
            }
        },
        {
            "type": "process",
            "label" : "kill_all_tasks",
            "command":[
                "${command:workbench.action.tasks.terminate}  terminateAll",
            ]
        }
发布评论

评论列表(0)

  1. 暂无评论