Visual Studio 2017 uses SSH to debug. NET Core and SSH on Linux
Visual Studio 2017 uses SSH to debug the. NET Core application on Linux.
Environment
Development Environment: Win10 x64 Visual Studio 2017
Deployment environment: Ubuntu 14.04x64. NET Core SDK 1.0.1
Install. NET Core SDK on Ubuntu
Ubuntu 14.04x64
sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list'sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 417A0893sudo apt-get update
If you have installed the preview version before, make sure to update it.
Install the latest SDK 1.0.1.
sudo apt-get install dotnet-dev-1.0.1
After the installation is complete, run dotnet -- info as follows:
Indicates that the SDK is successfully installed.
Next, you need to install the SSH server, unzip, curl, or wget on the Linux server. The command is as follows:
sudo apt-get install openssh-server unzip curl
After the installation is complete, everything is ready.
New program
Open VS 2017 and create a console application. NET Core named LinuxDemo.
Add the following code to Program. cs:
class Program { static void Main(string[] args) { Console.WriteLine("Hello World! LineZero"); Console.WriteLine("Linux .NET Core Debug"); Console.WriteLine("'q' exit"); while (true) { var result = Console.ReadLine(); if (result.Equals("q")) return; Console.WriteLine(result); } } }
After writing the code, upload the code to Ubuntu.
Then run the program on Ubuntu and run it successfully.
Dotnet restore
Dotnet build
Dotnet run
Additional debugging
Start the program by default, and enable debugging in VS 2017-> attach to the Process
Select SSH as the connection type, enter the Ubuntu IP address at the connection and destination, and press enter to bring up the dialog and enter the corresponding user name and password.
Configuration:
Additional process:
Select Type:
Next, wait a few characters in Linux and press enter to break down:
Note:
If you find that the append cannot be disconnected, stop debugging, restart VS, exit the program, run the program again, and then attach it. Try multiple times.
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.