This article mainly describes the VS2017 Linux on the. NET core debugging, small series feel very good, and now share to everyone, but also for everyone to make a reference. Let's take a look at it with a little knitting.
Visual Studio 2017 uses SSH to debug a. NET Core application on Linux.
This article environment
Development environment: WIN10 x64 Visual Studio 2017
Deployment environment: Ubuntu 14.04 x64. NET Core SDK 1.0.1
Install the. NET Core SDK on Ubuntu
Ubuntu 14.04 x64
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 previously installed the preview version, be sure to update it.
Then install the latest version of the SDK 1.0.1
sudo apt-get install dotnet-dev-1.0.1
After the installation is complete, execute dotnet--info as follows:
Indicates that the SDK installation was successful.
Then on the Linux server, you need to install the SSH server, unzip and curl or wget. The command is as follows:
sudo apt-get install openssh-server unzip Curl
When the installation is complete, everything is ready.
New program
Open vs 2017 Create a new console app. NET Core is 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);}}}
Write the code and upload the code to Ubuntu.
Then run the program on Ubuntu and execute it successfully.
dotnet Restore
dotnet Build
Dotnet Run
Additional debugging
The program is then run by default and then attached to the process with VS 2017 Open debug
Select the connection type is SSH, then connect and target the Ubuntu IP, then enter, the dialog will pop up, enter the corresponding user name password.
Configuration:
Additional processes:
Select Type:
Then wait for a few characters in the Linux input, enter the broken down:
Attention:
If you find that the attachment cannot be broken, stop debugging, restart VS, and then exit the program, rerun and then attach. Try a few more times.