install .NET on Debian

How to install .NET on Debian?

How To - A help section for how to do a task

Install .NET on Debian to get started with .NET

Let’s proceed towards the installation of .NET on Debian. Before moving towards .NET, you will need to setup few components in the system, registering of Microsoft signature key & Microsoft Product feed. You need to do this once per machine.

To install system components, open your command prompt or terminal and run the following commands.

~$ sudo apt-get update
~$ sudo apt-get install curl libunwind8 gettext apt-transport-https

Now register the trusted Microsoft Product key by using the following commands:

~$ curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
~$ sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg

Now register the Microsoft Product feed on Debian 9 (Stretch) by using the following commands:

~$ sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-stretch-prod stretch main" > /etc/apt/sources.list.d/dotnetdev.list'

OR register the Microsoft Product feed on Debian 8 (Jessie) by using the following commands:

~$ sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-jessie-prod jessie main" > /etc/apt/sources.list.d/dotnetdev.list'

Before you begin to install .NET SDK, use the following commands to update the products available for installation.

~$ sudo apt-get update
~$ sudo apt-get install dotnet-sdk-2.0.2

Now you have to create your app. Close the command prompt and reopen it. Now, type the following commands:

~$ dotnet new console -o myApp
~$ cd myApp

The dotnet command will create the new app of console type. The -o parameter will create new folder or directory naming it myApp. Your app and its files will be stored here. To navigate to newly created folder myApp, you will use cd myApp command. There will be a file Program.cs in myApp folder which contains hello world code.

using System;

namespace myApp

{

class Program{

static void Main(string[] args){

Console.WriteLine("Hello World");

}

}

}

 

Now its time to run your app. To run your app, open your command prompt or terminal and write the following command and press enter to execute.

~$ dotnet run

 

Thanks for reading our tutorial. Check more!

Leave a Reply

Your email address will not be published. Required fields are marked *