Как я могу отладить процесс в WSL2 от Rider?

#c# #debugging #wsl-2 #rider

Вопрос:

Я хотел бы отладить свой процесс .NET Core, работающий под управлением WSL2, но я не могу подключиться к нему из Rider в Windows. Есть ли способ достичь этого?

Ответ №1:

Вы можете рассматривать свой дистрибутив WSL2 как удаленную машину и использовать для этого инструменты удаленной отладки Rider. Инструкции в основном следуют тому, что описано здесь: https://www.jetbrains.com/help/rider/SSH_Remote_Debugging.html#set-up-ssh-server-on-the-remote-machine

В вашей консоли wsl2:

 $ # 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 ...