16
  • Docker
  • .NET Core 1.1
  • Visual Studio 2017
  • .NET Core Debugger (clrdbg)

I am receiving the following error:

"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

I will got step by step how I build my .NET Core Docker image and run a Container instance from this image, and then connect remote with Visual Studio 2017, my Dockerfile.debug is at the bottom of my question:

  1. on my docker host cd ~/repos/api.security //a git repository
  2. git pull //pull latest code from git for .NET Core project
  3. dotnet restore
  4. dotnet publish //with no other args publishes with .pdbs
  5. docker build -t tsl.api.security.image.debug -f Docker.debug .
  6. docker run -d -p 8080:5000 -p 10222:22 --name=tsl.api.security.container.debug -t tsl.api.security.image.debug //run and map my .NET Core Webapi in Container on port 5000 to host port 8080 and map ssh in the Container, port 22, to port 10222 on the host
  7. docker exec -it tsl.api.security.container.debug bash //terminal into running container from host
  8. /usr/sbin/sshd //start sshd

Ok great, now that container is ready for remoting debugging, using ssh with Visual Studio 2017, on my machine with Visual Studio 2017:

  1. pull latest code from git
  2. open .sln with Visual Studio 2016
  3. Build in Debug
  4. Go to Tools -> Options -> Cross Platform and my SSH Remote:enter image description here
  5. CTRL + ALT + P //attach to process
  6. Select Connection Type -> SSH enter image description here
  7. Select Managed (.NET Core for Unix) enter image description here

And viola! We have my issue: enter image description here

If we look at /app in my Docker Container we can see pdbs:enter image description here

And the source code is the same, as the git pull steps in my workflow explanation demonstrates.

Not sure where to go from here...

Here is my 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"]
3
  • Hi, I tried to debug from vs2017u3, did everything similar to yours with vsdbg but when getting some issues. At first, there was some connection timeout issue then I downloaded vsdbg into $HOME/.vs-debugger/ and now if I connect no error is coming but is exiting without attaching the process. Can you please help with this? Commented Sep 14, 2017 at 15:45
  • Got this error: Copying debugger launcher to /root/.vs-debugger/GetVsDbg.sh Failed: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond Commented Sep 14, 2017 at 16:03
  • This should have more votes. Had no idea this was even possible, great information. Commented Nov 6, 2017 at 2:02

1 Answer 1

7

Tools->Options->Debugging->General, turn off "Require source files to exactly match the original version". Not ideal, but at least it hits the breakpoint set in the source code in VS2017.

Please let me know once you find out how to properly fix this.

Sign up to request clarification or add additional context in comments.

2 Comments

Well that certainly works, thank you, not ideal but perhaps my only option at this point
Awesome, this got it working for me too. I had the exact same issue, but not using docker. It also just occurred to me that this may be caused by the line endings of the source file being different. I have almost the exact same deploy process as @brian-ogden. Git performs automatic newline conversion from \r\n to \n on Linux, so the source file that dotnet builds from on Linux is technically different than the source on Windows.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.