Visual Studio 2017 uses SSH to debug. NET Core and SSH on Linux

Source: Internet
Author: User
Tags ssh server

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.