vscode-csharp: Remote process picker does not work (attach to Docker container scenario)

Environment data

MacOS BigSur 11.4 .NET SDK 5.0.301 VS Code 1.57.0 C# extension 1.23.12 Docker extension 1.13.0 Docker Desktop for Mac version 3.3.3

OmniSharp log

Steps to reproduce

  1. Create new web API project: dotnet new webapi --no-https
  2. Open application folder in VS Code
  3. When prompted, add “required build files” to workspace
  4. Run Docker: add Docker files to workspace command. Select “.NET ASP.NET Core”, Linux, port 5000, yes to optional Docker Compose files
  5. Change first line of the Dockerfile so that it reads FROM mcr.microsoft.com/dotnet/aspnet:5.0-focal AS base (note the image tag is 5.0-focal, not just 5.0
  6. Right-click Dockerfile and choose “build image”
  7. Switch to Docker view (whale icon), right-click the application image (expand to see the “latest” tag), and choose “Run”
  8. Open .vscode/launch.json and add the following debug configuration
{
    "name": "Docker .NET Core Attach",
    "type": "docker",
    "request": "attach",
    "platform": "netCore",
    "processId": "${command:pickRemoteProcess}"
}
  1. Make the added debug configuration active and execute it. Select “Individual Containers” group, then the running application container. When prompted, allow debugger to be copied to the application container.

Expected behavior

After the debugger is copied to the application container, the user should be prompted to select the process to attach to.

Actual behavior

An error message that says “No process with the specified id is currently running”

Additional information

When Docker extension resolves the debug configuration, it will return the following:

{
  "name": "Docker .NET Core Attach",
  "justMyCode": false,
  "platform": "netCore",
  "processId": "${command:pickRemoteProcess}",
  "processName": undefined,
  "request": "attach",
  "type": "coreclr",
  "sourceFileMap": {
    "/src": "${workspaceFolder}"
  },
  "pipeTransport": {
    "debuggerPath": "/remote_debugger/vsdbg",
    "pipeCwd": "${workspaceFolder}",
    "pipeProgram": "docker",
    "quoteArgs":  false,
    "pipeArgs": [
      "exec",
      "-i",
      "application_container_name"
    ]
  }
}

(application_container_name is the name of the running application container)

This used to work until recently–the user would be prompted to select the process to attach to. I suspect https://github.com/OmniSharp/omnisharp-vscode/pull/4509 might have broken this scenario.

FWIIW, the following launch configuration works as expected (assuming debugger bits have been already copied into the container):

       {
            "name": "Manual Docker attach",
            "type": "coreclr",
            "justMyCode": false,
            "processId": "",
            "request": "attach",
            "sourceFileMap": {
                "/src": "${workspaceFolder}"
            },
            "pipeTransport": {
                "pipeCwd": "${workspaceFolder}",
                "pipeProgram": "docker",
                "pipeArgs": [
                    "exec",
                    "-i",
                    "application_container_name"
                ],
                "debuggerPath": "/remote_debugger/vsdbg",
                "quoteArgs": false
            }
        }

(leveraging the new functionality that prompts the user to select a process when processId is left empty)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 19 (18 by maintainers)

Most upvoted comments

Yep. That is exactly the launch.json configuration I used for testing and got a process listing.

image

Here is the vsix of the omnisharp-vscode extension with the ${command:pickRemoteDockerProcess} supported. csharp-1.23.13-pickDockerProcess.zip

So @WardenGnaw just to make sure I understand the implications: when new OmniSharp release ships, the following configuration should work (changing pickRemoteProcess to pickRemoteDockerProcess):

{
    "name": "Docker .NET Core Attach",
    "type": "docker",
    "request": "attach",
    "platform": "netCore",
    "processId": "${command:pickRemoteDockerProcess}"
}

Created a PR for the temporary workaround.