News & Updates

Install .NET on Ubuntu: The Ultimate Step-by-Step Guide

By Ethan Brooks 15 Views
install dotnet ubuntu
Install .NET on Ubuntu: The Ultimate Step-by-Step Guide

Installing the .NET SDK on Ubuntu is a straightforward process that unlocks a powerful environment for building modern, cross-platform applications. This guide walks you through each step, ensuring you can develop, test, and deploy C# and F# projects directly on your Linux machine.

Preparing Your Ubuntu System

Before adding new repositories, it is best to update your local package index and install essential dependencies. This ensures you have the latest security patches and the necessary tools for secure HTTPS communication.

Update and Install Prerequisites

Run the following commands in your terminal to prepare your system:

sudo apt update

sudo apt install -y wget apt-transport-https software-properties-common

These packages provide the foundation for adding the Microsoft package feed and installing the runtime.

Adding the Microsoft Repository

To receive updates and ensure authenticity, you must register the Microsoft signing key and add their Apt repository. This step configures your system to pull packages directly from the official source.

Register Key and Feed

Execute the following sequence to register the key and add the repository:

Command
Description
wget -q https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
Downloads the repository package.

sudo dpkg -i packages-microsoft-prod.deb

sudo apt update

Installing the .NET SDK

With the repository configured, you can now install the .NET SDK. This package includes the compiler, runtime, and command-line tools required for development.

Choose Your Version

You have the option to install the Long-Term Support (LTS) version for stability or the Current version for the latest features. To install the LTS version, use:

sudo apt install -y dotnet-sdk-8.0

For the Current version, replace the package name with dotnet-sdk-current .

Verifying the Installation

After the installation completes, you should confirm that the SDK is correctly installed and accessible from your shell.

Check Version and Integrity

Run the following command to display the installed SDK version:

dotnet --info

This command outputs detailed information about your runtime environment, confirming that the toolchain is ready for use.

Creating Your First Project

With the SDK installed, you can now create a new project to verify that the development workflow functions correctly. This helps ensure your toolchain is fully operational.

Build and Run a Console App

Follow these steps to create a simple "Hello World" application:

Create a new console project: dotnet new console -o HelloWorld

Navigate into the project directory: cd HelloWorld

E

Written by Ethan Brooks

Ethan Brooks is a Senior Editor covering consumer products and emerging ideas. He writes with precision and a bias toward action.