'How do I use Visual Studio 2019 to remotely debug a .NetCore application on a Hyper-V Linux VM?
I am attempting to remotely debug a .NetCore application in Ubuntu Linux from Visual Studio 2019 in Windows 10. I can see the remote ipaddress (ping thru command line). I can RDT to the ipaddress. I can successfully transfer files to it via WinSCP.
I created a simple .NetCore "HelloWorld" app and copied onto the Linux VM. I used the following commands to build and publish:
dotnet build -r linux-x64
dotnet publish --self-contained -r linux-x64
I ran the following command on the Linux VM to ensure that ssh is functional:
sudo apt-get install openssh-server unzip curl
The app is running on Linux. From VS I try to attach to the process:
I get prompted for logon:
I get the following error:
Is there a step I'm missing somewhere? Is there a configuration/permissions issue I am unaware of?
Thanks, JohnB
Solution 1:[1]
Microsoft has documented debugging a Linux target from a Windows development machine at https://docs.microsoft.com/en-us/visualstudio/debugger/remote-debugging-dotnet-core-linux-with-ssh?view=vs-2022
Unfortunately, using that method, you will need to manually deploy and manually attach the debugger. If you'd like Microsoft to change that, then it would be wise to upvote this issue: https://developercommunity.visualstudio.com/t/Convenient-way-to-add-a-remote-debug-con/917516
A 3rd party developer has created a Visual Studio extension that provides this missing feature to Visual Studio. It can be downloaded from https://github.com/radutomy/VSRemoteDebugger
Solution 2:[2]
I had the same problem initially because I didn't enter the connection target in the first screen. After having entered the correct target [email protected] in the first screen the second screen did not show up any longer and I got the expected list of processes
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Verax |
Solution 2 | ChristianJ |