.NET Core On Linux: Getting Started

In this article, we will discuss how we can setup .NET Core on Linux environment, Prerequisite, Developing a console application on Linux, etc. As we discussed understanding about .NET Core with hello world application on Windows in my previous articles. If you want to learn .NET Core and its features, you can read the below link:

Prerequisites

You have to download the following software's and install them on your PC

  • VMware 
  • Ubuntu 14.4 / Linux Mint 17
  • .NET Core SDK 1.0

VMware

  • You can download trial version and install VMware from the VMware site (or)
  • You can download open source and install Virtual Box from the Virtual Box Community site

Ubuntu 14.04

  • You can download and install the Ubuntu OS from the Ubuntu site

.NET Core SDK

  • You can download and install the .NET Core SDK as following commands:

“sudo apt-get install dotnet-dev-1.0.0-preview2-003131”

Implementation

You are able to implement .NET Core with different methods such as Command line and Visual Studio Code Editor

Setting up the Environment

Using the command line, procedures are given below:

If you want to know how to install the .NET Core on Ubuntu 14.4 / Linux Mint 17, let’s start with step-by-step guidelines,

  • Open the Terminal Emulator
  • Copy and paste the following command in Terminal, then enter:

“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 apt-mo.trafficmanager.net --recv-keys 417A0893”

Copy and paste the following command in terminal, then enter

“sudo apt-get update”

Copy and paste the following command in terminal, then enter

“sudo apt-get install dotnet-dev-1.0.0-preview2-003131”

Developing a Hello World Console Application on Linux

  • Type mkdir Project cd Project and enter in the command line.

  • Type mkdir ConsoleHelloWorldApp, cd ConsoleHelloWorldApp and enter in the command line.
  • Type dotnet new and enter in the command line, given below

  • Type dotnet restore and enter on the command line, given below

  • Type dotnet run and enter on the command line, given below

Developing a Display Current DateTime Console Application on Linux

  • Open program.cs with gedit 
  • You can implement the get current date time functional and call the function in the main method
  • Type dotnet run and enter on the command line, given below

Reference

Conclusion

We hope you understood the setup of .NET Core on a Linux environment, prerequisites, developing a console application on Linux and running it. We have covered all the required things. If you find anything that we missed in this article, please let us know. Please share your valuable feedback or suggestions.