Blog Emka

Portal linux, pemrograman sistem informasi, computer security & santri

Tutorial Linux

Ini Cara Install Microsoft .NET Core SDK di Linux! GAMPANG

Teknologi .NET dari Microsoft sebagai basis pembuatan berbagai aplikasi desktop buatan mereka di Windows. Tidak hanya itu, .NET sebenarnya bisa juga digunakan untuk membuat aplikasi Mobile, Website, IoT dan Game. Nah, di tutorial ini kita akan menginstall .NET Core SDK ini di Linux.

Dengan hadirnya SDK ini secara resmi, Microsoft membuka kesempatan buat kita-kita para pengembang software untuk melebarkan sayap membuat aplikasi di platform lain, misalnya di Linux. 

Tersedia Multiplatform

Microsoft .NET sudah tidak se-ekslusif dulu, sudah beberapa tahun ini, SDK yang dulunya khusus untuk platform Windows, sudah bisa dipasang juga di Linux dan Mac OS. Di Linux sendiri, dia tidak hanya bisa dipasang di satu distro saja, hampir semua bisa, semua distro linux popular bisa dipasangi .NET Core SDK.

Contoh instalasi .NET di Ubuntu 18.04 LTS

Silakan pasang repo baru dengan

wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo add-apt-repository universe

baru install aplikasinya dengan apt-get:

sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install dotnet-sdk-2.2

Contoh videonya:

Contoh instalasi .NET untuk Debian 9

Tambahkan dulu repo .NET

wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg
sudo mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/
wget -q https://packages.microsoft.com/config/debian/9/prod.list
sudo mv prod.list /etc/apt/sources.list.d/microsoft-prod.list
sudo chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg
sudo chown root:root /etc/apt/sources.list.d/microsoft-prod.list

baru kemudian dipasang:

sudo apt-get update
sudo apt-get install dotnet-sdk-2.2

Contoh Instalasi .NET untuk Debian 8

wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg
sudo mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/
wget -q https://packages.microsoft.com/config/debian/8/prod.list
sudo mv prod.list /etc/apt/sources.list.d/microsoft-prod.list
sudo chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg
sudo chown root:root /etc/apt/sources.list.d/microsoft-prod.list

kemudian install paketnya:

sudo apt-get update
sudo apt-get install dotnet-sdk-2.2

Contoh Instalasi .NET di Fedora 28:

Tambahkan dulu repo YUM:

sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
wget -q https://packages.microsoft.com/config/fedora/27/prod.repo
sudo mv prod.repo /etc/yum.repos.d/microsoft-prod.repo
sudo chown root:root /etc/yum.repos.d/microsoft-prod.repo

dan install menggunakan DNF:

sudo dnf update
sudo dnf install dotnet-sdk-2.2

Contoh Instalasi .NET di CentOS/Oracle Linux

sudo rpm -Uvh https://packages.microsoft.com/config/rhel/7/packages-microsoft-prod.rpm
sudo yum update
sudo yum install dotnet-sdk-2.2

Contoh Instalasi .NET di openSUSE Leap

Silakan tambahkan reponya:

$ sudo zypper install libicu
$ sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
$ wget -q https://packages.microsoft.com/config/opensuse/42.2/prod.repo
$ sudo mv prod.repo /etc/zypp/repos.d/microsoft-prod.repo
$ sudo chown root:root /etc/zypp/repos.d/microsoft-prod.repo

kemudian pasang dengan Zypper:

$ sudo zypper update
$ sudo zypper install dotnet-sdk-2.2

Uji Coba SDK

Untuk uji coba jika sudah memasang .NET Core SDK diatas di Linux masing-masing, silakan buat aplikasi sederhana dengan .NET core.

Buka terminal/console dan tulis:

dotnet new console -o emkaDotNetApp

akan keluar tampilan sbb:

Welcome to .NET Core!
---------------------
Learn more about .NET Core: https://aka.ms/dotnet-docs
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs

Telemetry
---------
The .NET Core tools collect usage data in order to help us improve your experience. The data is anonymous and doesn't include command-line arguments. The data is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.

Read more about .NET Core CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry

ASP.NET Core
------------
Successfully installed the ASP.NET Core HTTPS Development Certificate.
To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only). For establishing trust on other platforms refer to the platform specific documentation.
For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.
Getting ready...
The template "Console Application" was created successfully.

Processing post-creation actions...
Running 'dotnet restore' on ostechnixApp/ostechnixApp.csproj...
Restoring packages for /home/sk/ostechnixApp/ostechnixApp.csproj...
Generating MSBuild file /home/sk/ostechnixApp/obj/ostechnixApp.csproj.nuget.g.props.
Generating MSBuild file /home/sk/ostechnixApp/obj/ostechnixApp.csproj.nuget.g.targets.
Restore completed in 894.27 ms for /home/sk/ostechnixApp/ostechnixApp.csproj.

Restore succeeded.

Isinya kurang lebih sudah dibuatkan seperti ini:

using System;

namespace ostechnixApp
{
     class Program
     {
       static void Main(string[] args)
       {
         Console.WriteLine("Hello World!");
       }
   }
}

Ok, selanjutnya coba edit-edit aplikasi sederhana itu. Jika sudah, jalankan dengan perintah dotnet

dotnet run

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Theme by Anders Norén

%d bloggers like this: