How to Install .NET Core SDK on Fedora Linux

.NET Core is a robust, open-source framework that has become an essential tool for modern software development. With its flexible and scalable architecture, developers can build modern, cloud-based applications that run on multiple platforms, including Linux. In recent years, .NET Core has seen an increase in popularity among developers, so it is crucial to know how to install the .NET Core SDK on Linux systems.

The history of .NET Core and Linux has been remarkable, as Microsoft has made a conscious effort to embrace open-source technology and provide support for .NET Core on Linux systems. Today, .NET Core is widely used by developers for building cloud-based applications on Linux systems, and Fedora Linux is a popular choice for many of these developers.

The purpose of this article is to guide users through the process of installing the .NET Core SDK on Fedora Linux. With step-by-step instructions and FAQs, this comprehensive guide will help users get up and running with .NET Core on Fedora Linux in no time. Whether you’re new to .NET Core or a seasoned developer, this article has everything you need to know to start building applications with .NET Core on Fedora Linux.

Update Fedora

Before installing the .NET Core SDK, it is important to update your Fedora Linux system to ensure that you have the latest software updates. To do this, run the following command in the terminal.

sudo dnf upgrade --refresh

Method 1: Install .NET Core SDK with Fedora

The first method uses the default repositories of Fedora, which may be adequate.

To install the .NET 7 SDK on Fedora Linux, use the following command.

sudo dnf install dotnet-sdk-7.0

This command will install all the necessary dependencies, including the .NET runtime.

If you don’t want to install the entire SDK but want to run .NET 7 applications, you can install either the ASP.NET Core runtime or the .NET runtime using one of the following commands.

sudo dnf install aspnetcore-runtime-7.0

or

sudo dnf install dotnet-runtime-7.0

This style of package name applies to all versions of .NET on all versions of Fedora Linux. For example, to install .NET 6, you would use the following command.

sudo dnf install dotnet-sdk-6.0

More can be found by running a DNF search query if you are after specific packages.

dnf search dotnet-sdk*

Method 2: Install .NET Core SDK with Installer Script

The .NET development community has created a convenient script to simplify the installation process for the .NET SDK on Linux systems with BASH installed. The script can be run without user interaction or admin rights.

To get started, download the .NET installer script from the following link: https://dot.net/v1/dotnet-install.sh

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

Next, make the script executable by running this command.

sudo chmod +x ./dotnet-install.sh

Now, run the script to install the .NET SDK on your Linux system as a regular user.

./dotnet-install.sh

By default, the script installs the latest Long-Term Support (LTS) version of the .NET SDK, version 6. However, if you want to install version 7, use the following command.

./dotnet-install.sh --version latest

Use the following command to install the .NET Runtime instead of the SDK.

./dotnet-install.sh --version latest --runtime aspnetcore

You can install a specific major version using the following command, such as .NET 7.0 SDK.

./dotnet-install.sh --channel 7.0

Example output:

Finally, to complete the installation, add the dotnet PATH to your .bashrc or equivalent, log out, and log back in to apply the changes, for example.

export PATH=$PATH:$HOME/.dotnet
export DOTNET_ROOT=$HOME/.dotnet

Verify .NET Core SDK Installation

After following the steps to install the .NET Core SDK on Fedora Linux, you may want to verify the installation to ensure that it was successful and everything is working correctly. Here are some commands that you can use to check your installation.

Check the installed .NET Core SDK version with the following command.

dotnet --version

This will display the version of the .NET Core SDK installed on your machine.

Next, you can list the installed SDK versions with the following command.

dotnet --list-sdks

This will display all the .NET Core SDK versions installed on your machine and their paths.

Lastly, to list the installed runtime versions run the following command.

dotnet --list-runtimes

This will display all the .NET Core runtime versions installed on your machine and their paths.

Note, if you install

Testing .NET Core SDK Installation: Creating Your First App using Dotnet

The installation of .NET Core SDK can be tested by creating a simple application using the dotnet command line interface (CLI). This guide will go over creating a simple “Hello World” console application and a “Hello World” ASP.NET Core web application.

Example 1: Creating a Console Application

Step 1: Create a new Console Application project using the dotnet new console command.

dotnet new console -n HelloWorldApp

Step 2: Change the current directory to the newly created project directory.

cd HelloWorldApp

Step 3: Restore the dependencies and tools required for the project by running the following command.

dotnet restore

Step 4: Build the application using the following command.

dotnet build

Step 5: Finally, run the application using the following command.

dotnet run

The console will display the following output.

Hello World!

Example 2: Creating an ASP.NET Core Web Application

Step 1: Create a new ASP.NET Core Web Application project using the dotnet new MVC command.

dotnet new mvc -n HelloWorldWebApp

Step 2: Change the current directory to the newly created project directory.

cd HelloWorldWebApp

Step 3: Restore the dependencies and tools required for the project by running the following command.

dotnet restore

Step 4: Build the application using the following command.

dotnet build

Step 5: Finally, run the application using the following command.

dotnet run

You can access the application by navigating to http://localhost:5000 in your web browser.

Theory Behind the Test Steps

  • The dotnet new command creates a new .NET Core project with the specified template. The console template creates a simple console application, and the MVC template creates an ASP.NET Core web application.
  • The dotnet restore command is used to restore the dependencies and tools required by the project.
  • The dotnet build command is used to compile and build the project.
  • The dotnet run command is used to run the application.

By following these steps and testing the .NET Core SDK installation by creating a simple application, you can confirm that the installation was successful and that you can use the dotnet CLI to develop .NET Core applications.

How to Disable Telemetry with .NET Core SDK Telemetry

By default, the .NET Core SDK is equipped with a feature known as ‘Telemetry,’ which collects anonymous usage data. This data is shared with the development team and community under the Creative Commons Attribution License, allowing the .NET team to gain insight into how the tools are utilized and make improvements accordingly.

However, if you prefer to keep your user information private, opting out of telemetry using the following steps is simple. To disable telemetry in .NET Core SDK on Fedora by adding the following line, you can set the environment variable in your shell profile scripts, such as ~/.bashrc or ~/.bash_profile.

echo 'export DOTNET_CLI_TELEMETRY_OPTOUT=1' >> ~/.bashrc

Open a new terminal window and verify that the environment variable is set by executing the following command.

echo $DOTNET_CLI_TELEMETRY_OPTOUT

The output should be “1”.

That’s it! Telemetry is now disabled in .NET Core SDK on Fedora.

Conclusion

In conclusion, installing .NET Core SDK on Fedora is a simple process. With the help of the .NET installer script and the Linux terminal, users can easily install the latest version of the SDK or choose to install a specific version.

It is important to note that .NET Core SDK is a crucial tool for .NET developers as it provides a complete set of libraries and tools for building modern applications. The ability to run .NET on Linux platforms makes it a versatile and flexible tool for developers, which is why it is a highly recommended technology for building robust and scalable applications.

This article provides step-by-step instructions for downloading and installing the .NET Core SDK on Fedora. Additionally, we discussed how to verify the installation and disable telemetry, an optional feature that sends anonymous usage data to the .NET development team.

Overall, installing .NET Core SDK on Fedora is an excellent investment for developers who want to build modern applications using powerful and versatile technology. Whether you are a seasoned developer or just starting, .NET Core SDK is an excellent tool that provides all the necessary tools and libraries for building high-quality applications.

For more information on installing .NET Core SDK on Fedora Linux, you can refer to the official documentation: https://docs.microsoft.com/en-us/dotnet/core/install/linux-package-manager-fedora.

Frequently Asked Questions

Can I install the .NET Core SDK on any version of Fedora Linux?

Yes, you can install the .NET Core SDK on any version of Fedora Linux. The steps outlined in this article apply to all versions of Fedora Linux.

What if I encounter an error while installing the .NET Core SDK on Fedora Linux?

If you encounter an error while installing the .NET Core SDK on Fedora Linux, it is recommended that you check the error message and try to resolve the issue. You can also seek help from the Fedora Linux community or the .NET Core community for guidance.

Can I use the .NET Core SDK to build applications for other platforms?

Yes, you can use the .NET Core SDK to build applications for other platforms, including Windows and macOS. .NET Core is a cross-platform framework.

Is there a graphical user interface (GUI) option for installing .NET Core SDK on Fedora Linux?

No, there is no GUI option for installing .NET Core SDK on Fedora Linux. The process must be done using the command line.

Share to...