microsoft / vscode-docker

Docker Extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker
Other
1.21k stars 515 forks source link

Extension fails searching for container to attach before executing preLaunchTask #4096

Closed thefat32 closed 1 year ago

thefat32 commented 1 year ago

I have a preLaunchTask that starts the container but debug fails because extension is searching for container to attach before executing preLaunchTask.

launch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Docker NET Core Attach",
      "type": "docker",
      "request": "attach",
      "platform": "netCore",
      "preLaunchTask": "start:container",
      "sourceFileMap": {
        "/src": "${workspaceFolder}/src"
      },
      "processName": "dotnet"
    }
  ]
}

image

bwateratmsft commented 1 year ago

Unfortunately this is by-design from VSCode's perspective. Debug configurations are evaluated, and then the pre-launch tasks execute. That makes it impossible to use a pre-launch task to start a container ahead of "Docker .NET Core Attach". I'd really like to fix this but there's nothing we can do. 😞