加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

c# – 远程调试.NET Core Linux Docker容器 – “当前源与.dll中

发布时间:2020-12-16 03:38:08 所属栏目:安全 来源:网络整理
导读:Docker .NET Core 1.1 Visual Studio 2017 .NET核心调试器(clrdbg) 我收到以下错误: "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

> Docker
> .NET Core 1.1
> Visual Studio 2017
> .NET核心调试器(clrdbg)

我收到以下错误:

"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."

enter image description here

我将逐步了解如何构建我的.NET Core Docker镜像并从此图像运行Container实例,然后使用Visual Studio 2017连接远程,我的Dockerfile.debug位于我的问题的底部:

>在我的docker主机cd~ / repos / api.security //一个git存储库
> git pull //从git for .NET Core项目中提取最新代码
> dotnet恢复
> dotnet发布//没有其他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端口5000上的容器用于主机端口8080,并将容器(端口22)中的ssh映射到主机上的端口10222
> docker exec -it tsl.api.security.container.debug bash //终端从主机运行容器
> /usr/sbin / sshd //启动sshd

好的,现在该容器已准备好使用Visual Studio 2017在我的机器上使用Visual Studio 2017进行远程调试:

>从git中提取最新代码
>使用Visual Studio 2016打开.sln
>构建调试
>转到工具 – >选项 – >跨平台和我的SSH远程:

enter image description here


> CTRL ALT P //附加到进程
>选择连接类型 – > SSH

enter image description here


>选择托管(适用于Unix的.NET Core)

enter image description here

而中提琴!我们有我的问题:

enter image description here

如果我们在Docker Container中查看/ app,我们可以看到pdbs:

enter image description here

并且源代码是相同的,因为我的工作流程说明中的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@sessions*requireds*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"]
最佳答案
工具 – >选项 – >调试 – >常规,关闭“要求源文件与原始版本完全匹配”.不理想,但至少它会达到VS2017源代码中设置的断点.

一旦找到如何正确解决此问题,请通知我.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读