使用live watch在VS代码中调试dockerize ASP.Net核心应用程序
我试图在VS代码中设置dockerize ASP.Net核心WebAPI应用程序的调试。我能够调试应用程序。 但是,我无法设置live watch,无论何时在主机中更改源文件,docker应用程序都会重建和更新源映射文件并重新连接调试器。 当前,每次更改源文件时,我都需要手动重新启动调试 文件夹结构:使用live watch在VS代码中调试dockerize ASP.Net核心应用程序,docker,asp.net-core,visual-studio-code,vscode-debugger,Docker,Asp.net Core,Visual Studio Code,Vscode Debugger,我试图在VS代码中设置dockerize ASP.Net核心WebAPI应用程序的调试。我能够调试应用程序。 但是,我无法设置live watch,无论何时在主机中更改源文件,docker应用程序都会重建和更新源映射文件并重新连接调试器。 当前,每次更改源文件时,我都需要手动重新启动调试 文件夹结构: FROM microsoft/dotnet:2.2-sdk as DEV COPY ["CoreApi.csproj", "src/CoreApi.csproj"] RUN dotnet rest
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"]
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/CoreApi/CoreApi.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
]
}
{
"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" }]
}
}
]
}
开发。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"]
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/CoreApi/CoreApi.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
]
}
{
"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/task.json:
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"]
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/CoreApi/CoreApi.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
]
}
{
"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/launch.json:
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"]
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/CoreApi/CoreApi.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
]
}
{
"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中有一个未解决的问题