Skip to content

Manual set up for remote debugging in Rider

Fred Sladkey edited this page Apr 29, 2021 · 1 revision

Remote debugging in Rider

Example of enabling remote debugging in Rider for Cloud Code Sample project.

The team is still investigating an integrated solution for remote debugging in Rider. This is a guide to setting it up manually as a workaround in the meantime.

This configuration is not suitable for production, you may wish to create a separate Dockerfile with ssh configuration for debugging purposes, and use a separate skaffold profile for port forwarding. This guide shows the simplest version of the set up.

Set up SSH

Rider supports remote debugging via ssh, so we need to ensure ssh server is installed in our remote container and expose the connection via port forwarding.

Update your Dockerfile to

  • Install openssh-server.
  • Update your ssh config to allow for password authentication, and if necessary, enable log in as root.
  • Set the password for the user if it is not already set.
  • Enable ssh
  • Modify entrypoint to start SSH before starting the application
# Dockerfile
 RUN apt-get update \
-    && apt-get install -y unzip procps curl bash \
+    && apt-get install -y unzip procps curl bash openssh-server \
     && rm -rf /var/lib/apt/lists/*
+RUN echo 'root:<SOME_PASSWORD>' | chpasswd
+RUN echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config
+RUN echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
+RUN update-rc.d ssh enable

-ENTRYPOINT ["dotnet", "helloworld.dll"]
+ENTRYPOINT ["bash", "-c", "/etc/init.d/ssh start && dotnet helloworld.dll"]

Forward the port your ssh server is running on from the deployment you want to debug. I used the default port, 22, and chose to forward it to 5022.

// skaffold.yaml
portForward:
- resourceType: Deployment
  resourceName: dotnet-hello-world
  port: 22
  localPort: 5022

Create Remote Debug Configuration

In Settings | Build, Execution, Deploymnet | Debugger | Remote Debug, create a new connection config using localhost, the local port you chose from the previous step, and the ssh credentials for the container you want to debug.

Screen Shot 2021-04-13 at 11 22 26 AM

Start application in skaffold debug mode

Add a Cloud Code: Kubernetes run configuration to the project if it does not already exist (or from the tools menu, click Cloud Code | Kubernetes | Add Kubernetes Support) and start the run configuration in debug mode.

Attach to remote process

Once the application is running and skaffold has forwarded the ssh port, attach to the remote process by going to the run menu and clicking Attach to remote process.

Screen Shot 2021-04-13 at 11 27 47 AM

Install the debug tools

You will be prompted to install the debug tools on the remote container. If you don't see this prompt the first time you run Attach to remote process, just try running it again.

Screen Shot 2021-04-13 at 11 28 17 AM

Choose application to connect to

Once the debug tools have installed, you'll be prompted to choose which application to connect to.

Screen Shot 2021-04-13 at 11 28 44 AM

Happy debugging! 🎉

That's it! You should now be able to hit breakpoints in the application. Screen Shot 2021-04-13 at 11 29 32 AM