我收到以下错误:
"The breakpoint will not currently be hit. A copy of TokenController.cs was found in TSL.Security.Service.dll, but the current source code is different from the version built into the TSL.Security.Service.dll."
我将逐步了解如何构建我的 .NET Core Docker 镜像并从该镜像运行容器实例,然后使用 Visual Studio 2017 远程连接,我的 Dockerfile.debug 位于我的问题的底部:
cd ~/repos/api.security//一个 git 存储库 git pull//为 .NET Core 项目从 git 拉取最新代码dotnet 恢复dotnet publish//没有其他 args 使用 .pdbs 发布docker build -t tsl.api.security.image.debug -f Docker.debug .docker run -d -p 8080:5000 -p 10222:22 --name=tsl.api.security.container.debug -t tsl.api.security.image.debug//运行并将我的 .NET Core Webapi 在 Container 中的 5000 端口映射到主机端口 8080,并将 Container 中的 ssh 端口 22 映射到主机上的 10222 端口docker exec -it tsl.api.security.container.debug bash//从主机终端进入正在运行的容器/usr/sbin/sshd//启动sshd好的,现在容器已准备好进行远程调试,使用 ssh 和 Visual Studio 2017,在我的机器上使用 Visual Studio 2017:
如果我们查看我的 Docker 容器中的 /app,我们可以看到 pdbs:
并且源代码是相同的,正如我的工作流程解释中的 git pull 步骤所演示的那样。
不知道从这里去哪里......
这是我的 Dockerfile.debug:
# Use the standard Microsoft ASP.NET Core container
FROM microsoft/aspnetcore
# File Author / Maintainer
MAINTAINER Brian Ogden
WORKDIR /
RUN apt-get update && apt-get install -y unzip
RUN apt-get install -y openssh-server
RUN mkdir /var/run/sshd
RUN echo 'root:password' | chpasswd
RUN sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile
#install CLRDBG, Microsoft's new cross-platform command line debugger used for debugging code running on .NET Core
RUN curl -sSL https://aka.ms/getclrdbgsh | bash /dev/stdin vs2015u2 ~/clrdbg
# Copy our code from the "/src/MyWebApi/bin/Debug/netcoreapp1.1/publish" folder to the "/app" folder in our container
WORKDIR /app
COPY ./src/TSL.Security.Service/bin/Debug/netcoreapp1.1/publish .
# Expose port 80 for the Web API traffic
ENV ASPNETCORE_URLS http://+:5000
EXPOSE 5000 22
ENTRYPOINT ["dotnet", "TSL.Security.Service.dll"]
最佳答案
Tools->Options->Debugging->General,关闭“Require source files to fully match the original version”。不理想,但至少打到了VS2017中源代码设置的断点。
一旦您知道如何正确解决此问题,请告诉我。
关于c# - 远程调试 .NET Core Linux Docker 容器 - "the current source is different from the version built into .dll",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44401483/