How to install. Net 8 sdk on ubuntu 20. 04

How to Install .NET 8 SDK on Ubuntu 20.04

In this article, we will see how to install .NET 8 SDK on Ubuntu 20.04. The .NET SDK (Software Development Kit) is a set of tools, libraries, and frameworks provided by Microsoft for developing applications using the .NET platform. The .NET platform is a versatile and comprehensive framework that supports the creation of a wide range of applications, including web, mobile, desktop, gaming, and IoT (Internet of Things) applications, across various operating systems like Windows, macOS, and Linux.

It includes a vast set of standard libraries, known as the Base Class Library (BCL), which provides a wide range of functionalities like file I/O, database interaction, XML document manipulation, and many more. These libraries are the backbone of .NET applications. It comes with command-line tools like dotnet that allow developers to create, build, run, and publish their .NET applications from the command line. This tool is essential for automation and integration with various development tools and workflows. The .NET 8 SDK is the latest version available to use. Here we will see how to install .NET 8 SDK on Ubuntu 20.04. You can read more about .NET 8 on microsoft official

Sponsored
website.

 

How to install. Net 8 sdk on ubuntu 20. 04

How to Install .NET 8 SDK on Ubuntu 20.04

Also Read: How to Install Apache PHP Module on Ubuntu or Debian

Step 1: Prerequisites

a) You should have a running Ubuntu 20.04 Server.

b) You should have sudo or root access to run privileged commands.

c) You should have apt or apt-get and dpkg utility available in your Server.

d) You should have wget utility installed in your Server.

 

Step 2: Update Your Server

From time to time, ubuntu releases security patches and upgrades to keep system stable and secure. To install all those patches and updates, use sudo apt update && sudo apt upgrade command as shown below.

cyberithub@ubuntu:~$ sudo apt update && sudo apt upgrade
[sudo] password for cyberithub:
Hit:1 https://dl.winehq.org/wine-builds/ubuntu focal InRelease
Hit:2 http://in.archive.ubuntu.com/ubuntu focal InRelease
Hit:3 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:4 https://d3nt0h4h6pmmc4.cloudfront.net/ubuntu focal InRelease
Hit:5 https://dl.google.com/linux/chrome/deb stable InRelease
Hit:6 https://download.sublimetext.com apt/stable/ InRelease
Get:7 http://in.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Hit:8 https://ngrok-agent.s3.amazonaws.com buster InRelease
Ign:9 https://pkg.jenkins.io/debian-stable binary/ InRelease
Hit:10 https://pkg.jenkins.io/debian-stable binary/ Release
Hit:11 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/focal pgadmin4 InRelease
.................................................

 

See also  Ubuntu 20.04.4 LTS Released

 

Step 3: Download Repo

Since .NET SDK 4 can only be downloaded and installed from microsoft repo, you need to first download and install the repo package from microsoft official website to install SDK. For example, here we are downloading the repo package in current working directory by using below wget command.

cyberithub@ubuntu:~$ wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
--2023-12-17 20:16:05-- https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb
Resolving packages.microsoft.com (packages.microsoft.com)... 52.230.121.169
Connecting to packages.microsoft.com (packages.microsoft.com)|52.230.121.169|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3690 (3.6K) [application/octet-stream]
Saving to: ‘packages-microsoft-prod.deb’

packages-microsoft-prod.deb 100%[============================================================================>] 3.60K --.-KB/s in 0s

2023-12-17 20:16:06 (1.01 GB/s) - ‘packages-microsoft-prod.deb’ saved [3690/3690]

 

 

Step 4: Install Repo

To install debian package from current directory, use sudo dpkg -i packages-microsoft-prod.deb command as shown below. To know more about dpkg command, check 21+ Practical dpkg Command Examples for Linux Beginners.

cyberithub@ubuntu:~$ sudo dpkg -i packages-microsoft-prod.deb
[sudo] password for cyberithub:
Selecting previously unselected package packages-microsoft-prod.
(Reading database ... 318371 files and directories currently installed.)
Preparing to unpack packages-microsoft-prod.deb ...
Unpacking packages-microsoft-prod (1.0-ubuntu20.04.1) ...
Setting up packages-microsoft-prod (1.0-ubuntu20.04.1) ...

 

 

Step 5: Update Package Cache

After doing repo changes, it is mandatory to refresh package cache using sudo apt update command. This will update the repo list added along with all the packages information from the added repo.

cyberithub@ubuntu:~$ sudo apt update
[sudo] password for cyberithub:
Hit:1 https://dl.winehq.org/wine-builds/ubuntu focal InRelease
Hit:2 https://dl.google.com/linux/chrome/deb stable InRelease
Hit:3 https://d3nt0h4h6pmmc4.cloudfront.net/ubuntu focal InRelease
Get:4 https://packages.microsoft.com/ubuntu/20.04/prod focal InRelease [3,631 B]
Hit:5 https://download.sublimetext.com apt/stable/ InRelease
Hit:6 http://ppa.launchpad.net/flatpak/stable/ubuntu focal InRelease
Hit:7 https://ngrok-agent.s3.amazonaws.com buster InRelease
Hit:8 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:9 http://ppa.launchpad.net/gencfsm/ppa/ubuntu focal InRelease
Hit:10 http://ppa.launchpad.net/juju/stable/ubuntu focal InRelease
Hit:11 http://ppa.launchpad.net/libreoffice/ppa/ubuntu focal InRelease
Hit:12 http://ppa.launchpad.net/mojo-maintainers/ppa/ubuntu focal InRelease
Ign:13 https://pkg.jenkins.io/debian-stable binary/ InRelease
Hit:14 https://pkg.jenkins.io/debian-stable binary/ Release
Hit:15 http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu focal InRelease
Get:16 https://pkg.jenkins.io/debian-stable binary/ Release.gpg [833 B]
Hit:17 http://in.archive.ubuntu.com/ubuntu focal InRelease
Get:18 http://in.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:19 https://packages.microsoft.com/ubuntu/20.04/prod focal/main all Packages [2,714 B]
Hit:20 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/focal pgadmin4 InRelease
Get:21 https://packages.microsoft.com/ubuntu/20.04/prod focal/main arm64 Packages [52.5 kB]
Get:22 https://packages.microsoft.com/ubuntu/20.04/prod focal/main armhf Packages [17.7 kB]
Get:23 https://packages.microsoft.com/ubuntu/20.04/prod focal/main amd64 Packages [252 kB]
Get:24 https://repositories.timber.io/public/vector/deb/ubuntu focal InRelease [4,947 B]
Hit:25 http://in.archive.ubuntu.com/ubuntu focal-backports InRelease
Fetched 449 kB in 8s (57.7 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
9 packages can be upgraded. Run 'apt list --upgradable' to see them.

 

 

Step 6: Install .NET SDK 8

To install .NET SDK 8, use sudo apt-get install -y dotnet-sdk-8.0 command. This will download and install the package along with all its dependencies from Ubuntu repo.

cyberithub@ubuntu:~$ sudo apt-get install -y dotnet-sdk-8.0
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
aspnetcore-runtime-8.0 aspnetcore-targeting-pack-8.0 dotnet-apphost-pack-8.0 dotnet-host dotnet-hostfxr-8.0 dotnet-runtime-8.0 dotnet-runtime-deps-8.0
dotnet-targeting-pack-8.0 netstandard-targeting-pack-2.1
The following NEW packages will be installed:
aspnetcore-runtime-8.0 aspnetcore-targeting-pack-8.0 dotnet-apphost-pack-8.0 dotnet-host dotnet-hostfxr-8.0 dotnet-runtime-8.0 dotnet-runtime-deps-8.0
dotnet-sdk-8.0 dotnet-targeting-pack-8.0 netstandard-targeting-pack-2.1
0 upgraded, 10 newly installed, 0 to remove and 9 not upgraded.
Need to get 143 MB of archives.
After this operation, 581 MB of additional disk space will be used.
Get:1 https://packages.microsoft.com/ubuntu/20.04/prod focal/main amd64 dotnet-host amd64 8.0.0-1 [37.7 kB]
Get:2 https://packages.microsoft.com/ubuntu/20.04/prod focal/main amd64 dotnet-hostfxr-8.0 amd64 8.0.0-1 [108 kB]
Get:3 https://packages.microsoft.com/ubuntu/20.04/prod focal/main amd64 dotnet-runtime-deps-8.0 amd64 8.0.0-1 [2,890 B]
Get:4 https://packages.microsoft.com/ubuntu/20.04/prod focal/main amd64 dotnet-runtime-8.0 amd64 8.0.0-1 [23.1 MB]
Get:5 https://packages.microsoft.com/ubuntu/20.04/prod focal/main amd64 aspnetcore-runtime-8.0 amd64 8.0.0-1 [7,658 kB]
Get:6 https://packages.microsoft.com/ubuntu/20.04/prod focal/main amd64 dotnet-targeting-pack-8.0 amd64 8.0.0-1 [2,801 kB]
Get:7 https://packages.microsoft.com/ubuntu/20.04/prod focal/main amd64 aspnetcore-targeting-pack-8.0 amd64 8.0.0-1 [1,906 kB]
Get:8 https://packages.microsoft.com/ubuntu/20.04/prod focal/main amd64 dotnet-apphost-pack-8.0 amd64 8.0.0-1 [3,508 kB]
Get:9 https://packages.microsoft.com/ubuntu/20.04/prod focal/main amd64 netstandard-targeting-pack-2.1 amd64 2.1.0-1 [1,476 kB]
Get:10 https://packages.microsoft.com/ubuntu/20.04/prod focal/main amd64 dotnet-sdk-8.0 amd64 8.0.100-1 [102 MB]
Fetched 143 MB in 1min 16s (1,887 kB/s)
Selecting previously unselected package dotnet-host.
(Reading database ... 318379 files and directories currently installed.)
Preparing to unpack .../0-dotnet-host_8.0.0-1_amd64.deb ...
Unpacking dotnet-host (8.0.0-1) ...
Selecting previously unselected package dotnet-hostfxr-8.0.
Preparing to unpack .../1-dotnet-hostfxr-8.0_8.0.0-1_amd64.deb ...
.........................................................

 

 

Step 7: Verify Installation

You can verify the installation by listing the installed files path using dpkg -L dotnet-sdk-8.0 command as shown below.

cyberithub@ubuntu:~$ dpkg -L dotnet-sdk-8.0 
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/dotnet-sdk-8.0
/usr/share/doc/dotnet-sdk-8.0/changelog.Debian.gz
/usr/share/doc/dotnet-sdk-8.0/copyright
/usr/share/dotnet
/usr/share/dotnet/sdk
/usr/share/dotnet/sdk/8.0.100
/usr/share/dotnet/sdk/8.0.100/.toolsetversion
/usr/share/dotnet/sdk/8.0.100/.version
/usr/share/dotnet/sdk/8.0.100/AppHostTemplate
/usr/share/dotnet/sdk/8.0.100/AppHostTemplate/apphost
/usr/share/dotnet/sdk/8.0.100/Containers
/usr/share/dotnet/sdk/8.0.100/Containers/build
......................................................

 

 

Step 8: Check Version

You can also check the current installed .net sdk version by using dotnet --version command as shown below. As you can see, it is 8.0.100.

cyberithub@ubuntu:~$ dotnet --version
8.0.100

 

Step 9: List SDKs

To check list of SDKs installed in the system, run dotnet --list-sdks command as shown below.

cyberithub@ubuntu:~$ dotnet --list-sdks
8.0.100 [/usr/share/dotnet/sdk]

 

Step 10: List Runtimes

To check the list of runtimes available in system, use dotnet --list-runtimes command as shown below.

cyberithub@ubuntu:~$ dotnet --list-runtimes
Microsoft.AspNetCore.App 8.0.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

 

See also  TPM-backed Full Disk Encryption is coming to Ubuntu

Step 11: Create a C# Console Application Project

Now that dotnet is installed, let’s create a C# Console Application project by using dotnet new console command as shown below.

cyberithub@ubuntu:~$ dotnet new console
The template "Console App" was created successfully.

Processing post-creation actions...
Restoring /home/cyberithub/cyberithub.csproj:
Determining projects to restore...
Restored /home/cyberithub/cyberithub.csproj (in 1.08 sec).
Restore succeeded.

 

Step 12: Check all available options

To explore all the options available with dotnet utility, use dotnet help command as shown below.

cyberithub@ubuntu:~$ dotnet help
.NET SDK (8.0.100)
Usage: dotnet [runtime-options] [path-to-application] [arguments]

Execute a .NET application.

runtime-options:
  --additionalprobingpath    Path containing probing policy and assemblies to probe for.
  --additional-deps          Path to additional deps.json file.
  --depsfile                       Path to .deps.json file.
  --fx-version            Version of the installed Shared Framework to use to run the application.
  --roll-forward          Roll forward to framework version (LatestPatch, Minor, LatestMinor, Major, LatestMajor, Disable).
  --runtimeconfig                  Path to .runtimeconfig.json file.

path-to-application:
  The path to an application .dll file to execute.

Usage: dotnet [sdk-options] [command] [command-options] [arguments]

Execute a .NET SDK command.

sdk-options:
  -d|--diagnostics  Enable diagnostic output.
  -h|--help         Show command line help.
  --info            Display .NET information.
  --list-runtimes   Display the installed runtimes.
  --list-sdks       Display the installed SDKs.
  --version         Display .NET SDK version in use.
.............................................

 

Step 13: Uninstall .NET SDK 8

Once you are done using .NET SDK 8, you can choose to uninstall it from your system by using sudo apt remove dotnet-sdk-8.0 command as shown below. To remove all the dependencies with the package, use --auto-remove option with below command. Please keep in mind that removing dependent packages might cause irreparable losses in your system. So please be careful before removing any dependent packages.

cyberithub@ubuntu:~$ sudo apt remove dotnet-sdk-8.0
[sudo] password for cyberithub:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
aspnetcore-runtime-8.0 aspnetcore-targeting-pack-8.0 dotnet-apphost-pack-8.0 dotnet-host dotnet-hostfxr-8.0 dotnet-runtime-8.0 dotnet-runtime-deps-8.0
dotnet-targeting-pack-8.0 golang-1.13-go golang-1.13-race-detector-runtime golang-1.13-src golang-race-detector-runtime golang-src
libayatana-appindicator3-1 libayatana-indicator3-7 libwxbase3.0-0v5 libwxgtk3.0-gtk3-0v5 linux-headers-5.15.0-87-generic linux-hwe-5.15-headers-5.15.0-87
linux-image-5.15.0-87-generic linux-modules-5.15.0-87-generic linux-modules-extra-5.15.0-87-generic netstandard-targeting-pack-2.1
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
dotnet-sdk-8.0
0 upgraded, 0 newly installed, 1 to remove and 9 not upgraded.
After this operation, 400 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 323922 files and directories currently installed.)
Removing dotnet-sdk-8.0 (8.0.100-1) ...

After removing .net sdk package, you have to remove repo package as well by using sudo apt remove packages-microsoft-prod command as shown below.

cyberithub@ubuntu:~$ sudo apt remove packages-microsoft-prod
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
aspnetcore-runtime-8.0 aspnetcore-targeting-pack-8.0 dotnet-apphost-pack-8.0 dotnet-host dotnet-hostfxr-8.0 dotnet-runtime-8.0 dotnet-runtime-deps-8.0
dotnet-targeting-pack-8.0 golang-1.13-go golang-1.13-race-detector-runtime golang-1.13-src golang-race-detector-runtime golang-src
libayatana-appindicator3-1 libayatana-indicator3-7 libwxbase3.0-0v5 libwxgtk3.0-gtk3-0v5 linux-headers-5.15.0-87-generic linux-hwe-5.15-headers-5.15.0-87
linux-image-5.15.0-87-generic linux-modules-5.15.0-87-generic linux-modules-extra-5.15.0-87-generic netstandard-targeting-pack-2.1
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
packages-microsoft-prod
0 upgraded, 0 newly installed, 1 to remove and 9 not upgraded.
After this operation, 43.0 kB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 319610 files and directories currently installed.)
Removing packages-microsoft-prod (1.0-ubuntu20.04.1) ...


Discover more from Ubuntu-Server.com

Subscribe to get the latest posts sent to your email.

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply