question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remote process picker does not work (attach to Docker container scenario)

See original GitHub issue

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)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:19 (18 by maintainers)

github_iconTop GitHub Comments

3reactions
WardenGnawcommented, Jun 17, 2021

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

1reaction
karolz-mscommented, Jun 17, 2021

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}"
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Attach to running process inside docker from VS2017
I tried installing the vsdbg into the container along with ssh, but Visual Studio is not able to find any Remote Connections (in...
Read more >
Attach to a process running on a Docker container
To attach to a running process in a Linux Docker container: In Visual Studio, select Debug > Attach to Process (CTRL+ALT+P) to open...
Read more >
Attach to a running container - Visual Studio Code
To attach to a Docker container, either select Dev Containers: Attach to Running Container... from the Command Palette (F1) or use the Remote...
Read more >
Debugging your .NET Core in Docker applications with VS Code
We can run our application now by building that image and starting the container, but what happens if we want to debug it?...
Read more >
Attach to process | JetBrains Rider Documentation
Run | Attach to Process Ctrl+Alt+P. JetBrains Rider provides a way to attach the debugger to both local and remote processes.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found