How to install .NET on CentOS / Oracle?

How to install .NET on CentOS / Oracle?

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

Install .NET on CentOS or Oracle

To get started to install .NET on CentOS or Oracle, you need to add the dotnet product feed first. You will register Microsoft signature key. This is required once per machine.

Open your command prompt and execute the following commands:

~$ sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
~$ sudo sh -c 'echo -e "[packages-microsoft-com-prod]\nname=packages-microsoft-com-prod \nbaseurl= https://packages.microsoft.com/yumrepos/microsoft-rhel7.3-prod\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/dotnetdev.repo'

Now you will have to install the .NET SDK. To install .NET SDK, open your command prompt and execute the following commands:

~$ sudo yum update
~$ sudo yum install libunwind libicu
~$ sudo yum 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 *