VSCode 运行错误的预启动任务

VSCode Runs Wrong Prelaunch Task

在我的 launch.json 文件中,我为“Python Attach”配置定义了一个“preLaunchTask”——这里是摘录

{
            "name": "Python Attach",
            "type": "python",
            "request": "attach",            
            "pathMappings": [
                {
                   "localRoot": "${workspaceFolder}",
                    "remoteRoot": "/usr/src/app/mount"
                }
            ],
            "port": 5678,
            "host": "127.0.0.1",            
            "preLaunchTask": {
                "task": "Integration",
                "type": "docker-compose",
                "label": "Integration"                               
            }          
        }

我的 tasks.json 文件有两个使用不同 docker 文件的任务定义:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Integration",
            "type": "docker-compose",                     
            "dockerCompose": {
                "up": {
                    "detached": true,
                    "build": true,                    
                },
                "files": [
                    "${workspaceFolder}/docker-compose.debug.yml"
                ],                
            }     
        },              
        {
            "label": "Prod",
            "type": "docker-compose",            
            "dockerCompose": {
                "up": {
                    "detached": true,
                    "build": true,                    
                },
                "files": [
                    "${workspaceFolder}/docker-compose.yml"
                ],                
            }     
        }        
    ]
}

当我 运行 使用“Python Attach”配置的项目时,正在使用“Prod”任务而不是“Integration”任务。

我该如何解决这个问题?

似乎可以使用 preLaunchTask 定义内联任务定义。那不是我想要的。只需使用任务名称即可执行正确的任务。

而不是:

"preLaunchTask": {
                "task": "Integration",
                "type": "docker-compose",
                "label": "Integration"                               
            } 

我使用:

"preLaunchTask": "Integration"