Learn ( .NETcore) Programming on LinuxsteemCreated with Sketch.

in build-contest •  last month 

I had previously thought that programming (.NET) (pronounced "Dot net") would not be possible on Linux. After I learn and learn about (.NET) and the evidently can, not like what I thought before.

Image Source .NET platform

The world has changed.
Since then Microsoft CEO (Satya Nadella) has stated "Microsoft Love Linux" is that true?
There are several Microsoft products that have become open source, including (.NET) which have been open-sourced since 2014.


"Today (12 November 2014) is an extraordinary day for .NET! We are pleased to announce that .NET Core will be open source, including runtime and framework libraries.
This is a natural development from our open source efforts, which includes managed compilers (C #, VB, and F #) and ASP.NET:"


Microsoft programmers also contribute to many open source projects.
The proof, Microsoft became the organization that contributed the most to open source projects (on Github), defeating Facebook and Google.

Image Source Github Octoverse 2016

there is no more competition, so there will be collaboration and mutual cooperation to build a better ecosystem.
That is the spirit of open source.

On this occasion, I will write what I have learned / learned:
  • Introduction to C# and .NET
  • How to make a C# .NET program on Linux?
  • What tools are needed to create a C# .NET program on Linux?
  • How to Compile and Execute a C# .NET Program on Linux.

Now let's get into the .NET (point)

What are C# and .NET?

C# (pronounced "C Sharp") is a programming language made by Microsoft that is designed to run on .NET.
.NET itself is a platform for creating and running C#, F#, and VB programs. NET.

In .NET there are several components such as the Framework Class Library (FCL), WinForms, CLR, etc. that we can use to create programs.

Programs created for .NET will be executed by a virtual machine called Common Language Runtime (CLR).

So, if your computer is not already installed .NET, it won't be able to run programs created with C#, F#, and VB .NET.
If you've learned Java, .NET can be compared to JDK and JRE which can be used to create Java programs and run them.

.NET there are several types:

What are the differences?

The .NET Framework is a platform for creating Windows applications only;
.NET Core is a platform that can be used on various platforms such as Linux and MacOS;
XAMARIN is a .NET platform specifically for mobile.
Which .NET are we going to use?

Of course we will use the .NET Core.

Equipment that must be prepared

There are several tools that we must prepare to do C # programming on Linux:

Text Editor (Visual Studio Code) for writing program code;
Compiler (.NET SDK) for compiling program code.

That is all?
That's right, that's all.

Actually there are other alternatives, namely using Monodevelop. However, as of this writing, I will only use equipment from Microsoft.

1. Prepare the Text Editor

Why do you have to use VS Code, can you not use another text editor?

It could be ...

However, I recommend VS Code because there are extensions that we can use to debug C# programs.

Please install VS Code page for a complete list of available installation options.
Visual Studio Code is officially distributed as a Snap package in the Snap Store.
You can install it by running?

sudo snap install --classic code # or code-insiders

Note: If snap isn't available in your Linux distribution, please check the following Installing snapd guide, which can help you get that set up.

After that, install the C# extension.

This extension is a kind of plug-in that we will use to debug the program.

2. Installing the .NET SDK on Linux

Different distro also how to install it. I will install .NET on a Linux Mint 18.2 64-bit distro.
First we must add the .NET repository:

  • Download the package from Microsoft
  • Then install
sudo dpkg -i packages-microsoft-prod.deb

Note: this is for Ubuntu version 18.04, for other versions and distributions please check at https://docs.microsoft.com/id-id/dotnet/core/install/linux-package-manager-ubuntu-1804

Then, we can install .NET with the command:

sudo add-apt-repository universe
sudo apt-get update
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install dotnet-sdk-3.1 -y

Stove until the process is complete.

Image Source PetaniKode

After that, to ensure that .NET is installed correctly, try typing the command"dotnet --version".

Create New Project

Please open a terminal, then type the following command to create a C# .NET project

dotnet new console -o HelloApp


  • console is the kind of application we are going to create.
  • HelloApp is the name of the project project.

Apart from console applications there are also other types of applications such as ASP for Web applications.
We can see with dotnet new --help.

After we create the project, now we open it with a text editor.

Type the following command:

code HelloApp

Then it opens like this:

If the "Warning" message appears as above, just click "Yes".
We can start writing the program in the Program.cs file.

There may be some misunderstandings in writing please note, this tutorial is helpful.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!