我正在尝试在 VS Code 中设置 dockerize ASP.Net Core WebAPI 应用程序的调试。我能够调试应用程序。 但是,我无法设置实时监视,只要主机中的源文件发生更改,docker 应用程序就会重建并更新源映射文件并重新附加调试器。 目前,每次更改源文件时,我都需要手动重新启动调试。
文件夹结构:
development.docker 文件:
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" }]
}
}
]
}
最佳答案
目前看来是不可能的。这是 vscode-docker github repo 中关于此案例的未解决问题。
关于docker - 使用实时观察在 VS Code 中调试 dockerize ASP.Net Core 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57839424/