vscode Docker 调试 csharp.listRemoteProcess 失败

时间:2021-04-08 11:59:21

标签: docker visual-studio-code docker-compose .net-5

我有一个 .Net 5 WebApi,我想在 Docker 中托管和调试它。 当我运行 docker-compose 时,项目会正确启动。 附加调试器时,我收到以下错误: Running the contributed command csharp.listRemoteProcess failed

我的 docker 文件:

FROM mcr.microsoft.com/dotnet/sdk:5.0 as debug
ENV DOTNET_USE_POLLING_FILE_WATCHER=true  
ENV ASPNETCORE_URLS=http://+:5000
EXPOSE 5000/tcp
WORKDIR /app
COPY . /app
RUN apt-get update
RUN apt-get install -y unzip
RUN curl -sSL https://aka.ms/getvsdbgsh | /bin/sh /dev/stdin -v latest -l ~/vsdbg
ENTRYPOINT ["dotnet", "watch", "run", "--project myproject.csproj"]

docker-compose 文件

version: '3.4'
services: 
  server:
    build: 
      context: ./myproject
      target: debug
    ports: 
      - "5000:5000"
    container_name: myproject
    volumes:
      - ./myproject:/app

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": ".NET Core Docker Attach",
            "type": "coreclr",
            "request": "attach",
            "processId": "${command:pickRemoteProcess}",
            "pipeTransport": {
                "pipeProgram": "docker",
                "pipeArgs": [ "exec", "-i", "csharp" ],
                "debuggerPath": "/root/vsdbg/vsdbg",
                "pipeCwd": "${workspaceRoot}",
                "quoteArgs": false
            },
            "sourceFileMap": {
                "/work": "${workspaceRoot}/myproject/"
            }
        }
    ]
}

0 个答案:

没有答案