8

I'd like to debug my .NET Core process running under WSL2, but I can't attach to it from Rider in Windows. Is there a way to achieve this?

Tim Barrass
  • 4,813
  • 2
  • 29
  • 55

1 Answers1

10

You can treat your WSL2 distribution as a remote machine and use Rider's remote debugging tools to achieve this. The instructions basically follow what's documented here: https://www.jetbrains.com/help/rider/SSH_Remote_Debugging.html#set-up-ssh-server-on-the-remote-machine

In your wsl2 console:

$ # fetch the jetbrains debug agent
$ cd ~
$ wget -o jetbrains-debug-agent https://www.jetbrains.com/help/rider/SSH_Remote_Debugging.html#set-up-ssh-server-on-the-remote-machine
$ chmod +x jetbrains-debug-agent
$ ./jetbrains-debug-agent
Please, use these credentials to establish SSH connection
Login:  xxxxxxxx
Password:  xxxxxxxxxxxxxxx
Port:  1234

$ # then determine your local IP address
$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.11.60  netmask 255.255.240.0  broadcast 192.168.15.255
...

$ # then, in Rider, choose Run > Attach To Remote Process
$ # it'll ask you to setup connection details for the remote machine
$ # it'll tell you that it needs to install remote debug components; you'll need to agree
$ # then attach ...
Tim Barrass
  • 4,813
  • 2
  • 29
  • 55