dotnet/vscode-csharp

Make csharp.listRemoteProcess support images without ps

gregg-miskelly opened this issue · 2 comments

Issue Description

The csharp.listRemoteProcess command would be helpful in Docker extension scenarios, because our debugging all happens through a pipe program (namely, docker exec). However, the implementation of it doesn't work in the Debian .NET base image because ps isn't present.

Steps to Reproduce

  1. Scaffold a .NET (Core) app
  2. With the C# extension, add the build and debug assets
  3. With the Docker extension, do Add Dockerfiles.... Say "Yes" to Compose files.
  4. Right click docker-compose.yaml and do Compose Up.
  5. Go to the Debug tab. Add a debug configuration for "Docker .NET Core Attach (Preview)". Add "processId": "${command:csharp.listRemoteProcess}" to that config. (Ordinarily this isn't needed since only one dotnet process exists in the container, but in some scenarios--like dotnet watch--more than one exists)
  6. F5 that config

Expected Behavior

Remote processes are listed to pick from

Actual Behavior

Error popup reading "See remote-attach output".

On a Debian image:

Executing: docker exec -i netcore2020_netcore2020_1 sh -s < "c:\Users\bwater\.vscode\extensions\ms-dotnettools.csharp-1.23.1\scripts\remoteProcessPickerScript"
Linux
stderr: sh: 1: ps: not found
Error Message: Command failed: docker exec -i netcore2020_netcore2020_1 sh -s < "c:\Users\bwater\.vscode\extensions\ms-dotnettools.csharp-1.23.1\scripts\remoteProcessPickerScript"
sh: 1: ps: not found

Changing the implementation of this to avoid ps, or adding an alternative command that uses OS APIs*, would enable this scenario.

*Note: VSDBG is present in the container so scripts are not the only option

Work around

Modify your docker file to add the procps package.

This is implemented now in 1.25.0 and should work in both Alpine and Debian based Docker images

Thanks for confirming @ssaraswati. Closing this issue.