In my launch.json file I have defined a "preLaunchTask" for the "Python Attach" configuration - here is an excerpt
{
"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"
}
}
My tasks.json file has two task definitions using different docker files:
{
"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"
],
}
}
]
}
When I run the project with the "Python Attach" configuration the "Prod" task is being used instead of the "Integration" task.
How can I fix this?
It seems with the preLaunchTask one can define in-line task definitions. That's not what I wanted. By just using the task-name the correct task is being executed.
Instead of:
"preLaunchTask": {
"task": "Integration",
"type": "docker-compose",
"label": "Integration"
}
I use:
"preLaunchTask": "Integration"