Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

VS Attach To Process

I get prompted for logon:

Log on to remote connection

I get the following error:

Error Message

Is there a step I'm missing somewhere? Is there a configuration/permissions issue I am unaware of?

Thanks, JohnB

like image 351
JohnB Avatar asked Dec 10 '25 02:12

JohnB


1 Answers

Microsoft has documented debugging a Linux target from a Windows development machine at https://learn.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

like image 155
Verax Avatar answered Dec 12 '25 10:12

Verax



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!