Friday, January 10, 2025
Google search engine
HomeGuest BlogsInstall .NET Core 6.0 on Rocky Linux 8|AlmaLinux 8|RHEL 8

Install .NET Core 6.0 on Rocky Linux 8|AlmaLinux 8|RHEL 8

.tdi_3.td-a-rec{text-align:center}.tdi_3 .td-element-style{z-index:-1}.tdi_3.td-a-rec-img{text-align:left}.tdi_3.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_3.td-a-rec-img{text-align:center}}

In this article we shall perform the installation of .NET Core 6.0 on Rocky Linux 8|AlmaLinux 8|RHEL 8. .NET is a developer platform comprised of programming languages, tools, and libraries that helps Developers in building different types of applications. ASP.NET frameworks extends the .NET developer platform with tools and libraries that enables building of web apps to be smooth and easy. As of the writing of this article, the latest release of .NET Core is 6.0, which is an LTS version.

The .NET 6.0 LTS releases are available for download on Windows, Linux and macOS operating systems. The package includes the .NET Runtime and ASP.NET Core Runtime. There is ASP.NET Core Module for IIS users which can be installed separately on servers without installing .NET Runtime.

The following distributions are available for Linux:

.tdi_2.td-a-rec{text-align:center}.tdi_2 .td-element-style{z-index:-1}.tdi_2.td-a-rec-img{text-align:left}.tdi_2.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_2.td-a-rec-img{text-align:center}}

  • .NET SDK: Includes tools for building and testing applications, and includes the runtime distributions that follow.
  • .NET Runtime: Includes the .NET runtime and libraries, enabling running console applications.
  • ASP.NET Core Runtime: Includes the .NET and ASP.NET Core runtimes, enabling running console, and web applications.

Install .NET Core 6.0 on Rocky Linux 8|AlmaLinux 8|RHEL 8

As a developer, you can install the .NET SDK to develop and build applications. Once the applications have been tested, one of the runtimes packages (like ASP.NET Core) is needed to exclusively run applications.

Install.NET SDK 6 on Rocky Linux 8|AlmaLinux 8|RHEL 8

The included runtimes are:

  • .NET Runtime
  • ASP.NET Core Runtime
  • .NET Desktop Runtime

We’ll use the dotnet-install scripts to automate the installation of the SDK and Runtime on our Linux system. The script defaults to installing the latest SDK long term support (LTS), which as of updating this article is 6.0 LTS.

Install wget or curl downloader:

sudo dnf -y install wget curl

Download .NET installer script locally:

#Using curl
curl -sLO https://dot.net/v1/dotnet-install.sh

#Using wget
wget https://dot.net/v1/dotnet-install.sh

Give the script execution bit:

chmod +x dotnet-install.sh

Script option that we’ll use:

  • -c,–channel: Download from the channel specified, Defaults to LTS.

Running the following command will install .NET SDK 6.0.

$ ./dotnet-install.sh -c 6.0
dotnet-install: Note that the intended use of this script is for Continuous Integration (CI) scenarios, where:
dotnet-install: - The SDK needs to be installed without user interaction and without admin rights.
dotnet-install: - The SDK installation doesn't need to persist across multiple CI runs.
dotnet-install: To set up a development environment or to run apps, use installers rather than this script. Visit https://dotnet.microsoft.com/download to get the installer.

dotnet-install: Downloading primary link https://dotnetcli.azureedge.net/dotnet/Sdk/6.0.101/dotnet-sdk-6.0.101-linux-x64.tar.gz
dotnet-install: Extracting zip from https://dotnetcli.azureedge.net/dotnet/Sdk/6.0.101/dotnet-sdk-6.0.101-linux-x64.tar.gz
dotnet-install: Adding to current process PATH: `/home/rocky/.dotnet`. Note: This change will be visible only when sourcing script.
dotnet-install: Note that the script does not resolve dependencies during installation.
dotnet-install: To check the list of dependencies, go to https://docs.microsoft.com/dotnet/core/install, select your operating system and check the "Dependencies" section.
dotnet-install: Installation finished successfully.

To install the current LTS release, use:

$ ./dotnet-install.sh -c Current

For the installation of .NET Runtime instead of the SDK, use the –runtime parameter.

$ ./dotnet-install.sh -c Current --runtime aspnetcore

Add .NET binaries directory to your PATH

Add ~/.dotnet/ to your PATH environment variable:

echo 'export PATH=$PATH:~/.dotnet/' | tee -a ~/.bashrc

Confirm it works:

$ source  ~/.bashrc
$ echo $PATH
$ echo $PATH
/home/rocky/.local/bin:/home/rocky/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/rocky/.dotnet/

Try run dotnet command to check version:

$ dotnet --version
6.0.101

Create hello world test

$ dotnet new console -o helloworld

Welcome to .NET 6.0!
---------------------
SDK Version: 6.0.101

Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It 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 CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry

----------------
Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only).
Learn about HTTPS: https://aka.ms/dotnet-https
----------------
Write your first app: https://aka.ms/dotnet-hello-world
Find out what's new: https://aka.ms/dotnet-whats-new
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
--------------------------------------------------------------------------------------
The template "Console App" was created successfully.

Processing post-creation actions...
Running 'dotnet restore' on /home/rocky/helloworld/helloworld.csproj...
  Determining projects to restore...
  Restored /home/rocky/helloworld/helloworld.csproj (in 97 ms).
Restore succeeded.

Run the app

$ cd helloworld
$ dotnet run
Hello, World!

Enable TAB completion for the .NET CLI

Tab completion for the .NET CLI is triggered by typing a dotnet command in the shell, and then pressing the TAB key. Set for your Shell as shown below.

Bash

To add tab completion to your bash shell for the .NET CLI, add the following code to your .bashrc file:

$ vim ~/.bashrc
# bash parameter completion for the dotnet CLI

_dotnet_bash_complete()
{
  local word=${COMP_WORDS[COMP_CWORD]}

  local completions
  completions="$(dotnet complete --position "${COMP_POINT}" "${COMP_LINE}" 2>/dev/null)"
  if [ $? -ne 0 ]; then
    completions=""
  fi

  COMPREPLY=( $(compgen -W "$completions" -- "$word") )
}

complete -f -F _dotnet_bash_complete dotnet

Zsh

To add tab completion to your zsh shell for the .NET CLI, add the following code to your .zshrc file:

$ vim ~/.zshrc
# zsh parameter completion for the dotnet CLI

_dotnet_zsh_complete()
{
  local completions=("$(dotnet complete "$words")")

  reply=( "${(ps:\n:)completions}" )
}

compctl -K _dotnet_zsh_complete dotnet

Tab completion usage examples:

install dotnet core rocky alma rhel linux

Conclusion

The .NET is a cross-platform developer platform created to help you in building your applications. .NET applications can be written in C#, F#, or Visual Basic programming languages. In this article, we’ve been able to install .NET Core 6.0 on Rocky Linux 8|AlmaLinux 8|RHEL 8 Linux systems. From this point you can start building apps with .NET for Mobile, Web, Cloud, Desktop, Machine Learning, Game development, Internet of Things, Microservices and for many other platforms.

.tdi_4.td-a-rec{text-align:center}.tdi_4 .td-element-style{z-index:-1}.tdi_4.td-a-rec-img{text-align:left}.tdi_4.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_4.td-a-rec-img{text-align:center}}

RELATED ARTICLES

Most Popular

Recent Comments