【问题标题】:Debugging dockerize ASP.Net Core app in VS Code with live watch使用实时监视在 VS Code 中调试 dockerize ASP.Net Core 应用程序
【发布时间】:2019-09-08 05:34:26
【问题描述】:

我正在尝试在 VS Code 中设置 dockerize ASP.Net Core WebAPI 应用程序的调试。我能够调试应用程序。 但是,我无法设置实时监视,只要主机中的源文件发生更改,docker 应用程序就会重建并更新源映射文件并重新附加调试器。 目前每次修改源文件都需要手动重启调试。

文件夹结构:

development.dockerfile:

FROM microsoft/dotnet:2.2-sdk as DEV
COPY ["CoreApi.csproj", "src/CoreApi.csproj"]
RUN dotnet restore "src/CoreApi.csproj"
RUN apt-get update
RUN apt-get install -y curl unzip
RUN apt-get install -y procps
RUN curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l /publish/vsdbg
ENV DOTNET_USE_POLLING_FILE_WATCHER 1
WORKDIR /src
COPY . .
EXPOSE 80
ENTRYPOINT ["dotnet", "watch", "run", "--urls=http://+:80"]

.vscode/task.json:

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "build",
      "command": "dotnet",
      "type": "process",
      "args": [
        "build",
        "${workspaceFolder}/CoreApi/CoreApi.csproj",
        "/property:GenerateFullPaths=true",
        "/consoleloggerparameters:NoSummary"
      ],
      "problemMatcher": "$msCompile"
    }
  ]
}

.vscode/launch.json:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "API Launch (Docker Watch)",
      "type": "docker-coreclr",
      "request": "launch",
      "preLaunchTask": "build",
      "dockerBuild": {
        "dockerfile": "${workspaceFolder}/CoreApi/.docker/development.dockerfile",
        "context": "${workspaceFolder}/CoreApi",
        "target": "DEV"
      },
      "appProject": "${workspaceFolder}/CoreApi/CoreApi.csproj",
      "dockerRun": {
        "ports": [
          {
            "hostPort": "5001",
            "containerPort": "80"
          }
        ],
        "volumes": [{ "localPath": "${workspaceFolder}/CoreApi/", "containerPath": "/src" }]
      }
    }
  ]
}

【问题讨论】:

    标签: docker asp.net-core visual-studio-code vscode-debugger


    【解决方案1】:

    目前看来不可能。这是 vscode-docker github repo 中关于此案例的一个未解决问题。

    [.NET Core Debugging] Debug with dotnet watch

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-26
      • 2020-06-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-16
      • 2019-07-26
      • 2017-03-22
      相关资源
      最近更新 更多