The .NET Core SDK is a powerful, versatile framework designed for developing a wide range of applications, from web to mobile and beyond. In this guide, we’ll focus on the straightforward process of how to install .NET Core SDK on Fedora Linux. This installation will enable developers to leverage .NET Core’s robust features on one of the most popular Linux distributions.
Key Features of .NET Core SDK:
- Cross-platform Support: Build and run applications across multiple platforms.
- Modular Design: Offers flexibility with its lightweight and modular framework.
- High Performance: Optimized for performance, it provides fast execution of applications.
- Open Source: Enjoy a community-driven approach with open-source availability.
- Command-line Tools: Simplifies development with powerful command-line tools.
- Extensive Libraries: Access a wide range of libraries for various functionalities.
- Flexible Deployment: Supports flexible deployment options, including self-contained deployments.
This guide ensures you are equipped with the necessary steps to integrate .NET Core SDK into your Fedora Linux system, thereby opening doors to a rich development experience. Let’s dive into the installation process.
Table of Contents
Install .NET Core SDK on Fedora Linux via Default Appstream
Step 1: Refresh Fedora Packages Before .Net Core SDK Installation
Begin by updating your Fedora Linux system. This step is crucial to ensure that all software on your system is up-to-date.
Use the command below in your terminal to update your system:
sudo dnf upgrade --refresh
This command refreshes your system’s package list and updates the software to the latest versions available in the repositories. It’s a best practice to perform this step before installing new software to avoid conflicts with outdated packages.
Step 2: Search for Dotnet-SDK
Fedora’s default repositories usually contain the .NET SDK. To verify its presence and check available versions, execute the following command:
sudo dnf search dotnet-sdk
This command lists all the .NET SDK versions available in Fedora’s repositories. It’s a good way to check for the latest version or a specific version you need.
Step 3: Install Dotnet-SDK via DNF Command
After identifying the desired version of .NET SDK, use the DNF package manager to install it. For instance, to install .NET SDK 7.0, use:
sudo dnf install dotnet-sdk-7.0
This command installs the .NET Core SDK version 7.0 along with all required dependencies, including the .NET runtime. It ensures that your Fedora system is equipped with the necessary tools to develop and run .NET applications.
Alternative Runtime Installations
In case you don’t need the full SDK but want to run applications built with .NET 7, you can opt to install just the runtime.
For ASP.NET Core applications, use:
sudo dnf install aspnetcore-runtime-7.0
For general .NET applications, the following command will suffice:
sudo dnf install dotnet-runtime-7.0
These commands are streamlined for Fedora Linux and apply to all versions of .NET. For instance, to install .NET 6 SDK, the command would be:
sudo dnf install dotnet-sdk-6.0
To explore more specific or different packages of .NET SDK, you can expand your search with a wildcard query:
dnf search dotnet-sdk*
This search will return a list of all .NET SDK-related packages, providing you with additional options for installation.
Install .NET Core SDK on Fedora via Installer Script
Utilizing the .NET Installer Script
For a seamless installation of the .NET SDK on Linux systems, including Fedora, the .NET development community provides an efficient script. This script streamlines the installation process and is user-friendly, requiring no administrative privileges.
Start by downloading the script:
This command fetches the .NET installer script from the official source, ensuring you get the latest version of the script.
Preparing the Script for Execution
Once downloaded, the script needs permission to execute. Achieve this by altering its permissions:
sudo chmod +x ./dotnet-install.sh
This command modifies the script, granting it executable rights, which is necessary to run the script on your system.
Running the Installation Script
To install the .NET SDK, execute the script as a regular user:
By default, this script installs the latest Long-Term Support (LTS) version of the .NET SDK. If you prefer the latest version, such as version 7, use the following command:
./dotnet-install.sh --version latest
To install only the .NET Runtime, particularly for ASP.NET Core applications, use:
./dotnet-install.sh --version latest --runtime aspnetcore
For installing a specific major version, like .NET 7.0 SDK, utilize the channel parameter:
./dotnet-install.sh --channel 7.0
Setting up Environment Variables
After installation, integrate .NET into your system environment. Add the .NET path to your shell profile, such as
.bashrc, then re-login to apply these changes. Use these commands:
These commands add the .NET directory to your PATH, making the .NET SDK accessible from any terminal session.
Verify .NET Core SDK Installation
Post-installation, confirm that the .NET Core SDK is correctly installed and operational.
Check Installed .NET Core SDK Version
To verify the installed version of .NET Core SDK, use:
This command displays the currently installed .NET Core SDK version, confirming the installation.
List All Installed .NET SDKs
To view all installed .NET SDK versions and their locations, execute:
This provides a comprehensive list of all the .NET SDK versions available on your system.
List Installed .NET Runtimes
For a detailed view of all installed .NET runtime versions, use:
This command lists all the .NET runtimes installed, along with their paths, offering insight into the runtimes available for your applications.
Testing .NET Core SDK Installation on Fedora Linux
Creating a Console Application
Step 1: Create a Console Application Project
Initiate the creation of a new console application by executing the following command:
dotnet new console -n HelloWorldApp
This command utilizes the
dotnet new console template to create a basic console application named
Step 2: Navigate to Project Directory
Switch to the directory of the newly created project:
This step changes your current directory to
HelloWorld App, where the project files are located.
Step 3: Restore Project Dependencies
To restore necessary dependencies and tools, run:
This command fetches all the required packages and tools that the project depends on, as defined in the project file.
Step 4: Build the Application
Compile and build the application using:
This command compiles the application, ensuring that all the dependencies are correctly resolved and the application is ready to run.
Step 5: Run the Application
Execute the application with:
Upon successful execution, the console should display:
This output confirms the proper functioning of the .NET Core SDK for console applications.
Creating an ASP.NET Core Web Application
Step 1: Create an ASP.NET Core Web Application Project
Start by creating a new ASP.NET Core web application:
dotnet new mvc -n HelloWorldWebApp
This command generates a new project based on the MVC (Model-View-Controller) template, creating a structure suitable for a web application.
Step 2: Change to Web Application Directory
Move into the project directory:
This change of directory is essential to perform subsequent operations within the context of the new web application.
Step 3: Restore Web Application Dependencies
Restore the project’s dependencies:
Similar to the console application, this command ensures all dependencies for the web application are installed.
Step 4: Build the Web Application
Build the application:
This step compiles the web application, checking for any compilation errors and preparing it for execution.
Step 5: Run the Web Application
Launch the application:
The web application starts, and it can be accessed via a web browser at
Understanding the Test Steps
- dotnet new: This command is foundational in creating new .NET Core projects. It prepares the necessary files based on the specified template, like
consolefor console applications or
MVCfor web applications.
- dotnet restore: This restores the project’s dependencies and tools, ensuring that all required packages are available for the application.
- dotnet build: It compiles the project, transforming source code into an executable program.
- dotnet run: This command launches the application, making it ready for testing or deployment.
These steps validate the functionality of the .NET Core SDK on Fedora Linux, demonstrating the capability to create, build, and run different types of .NET applications.
Disable Telemetry with .NET Core SDK Telemetry
Understanding .NET Core SDK Telemetry
The .NET Core SDK includes a telemetry feature that automatically collects anonymous usage data. This data, shared under the Creative Commons Attribution License, provides the .NET team with valuable insights into tool usage patterns, assisting them in making informed improvements.
Opting Out of Telemetry
For users who prioritize privacy and prefer not to share usage data, disabling telemetry is a straightforward process.
Set the Environment Variable
To turn off telemetry, add an environment variable to your shell profile. This can be done in either
~/.bash_profile, depending on your setup. Execute the following command:
echo 'export DOTNET_CLI_TELEMETRY_OPTOUT=1' >> ~/.bashrc
This command appends the
DOTNET_CLI_TELEMETRY_OPTOUT variable set to
1 in your
.bashrc file. The value
1 indicates the deactivation of telemetry.
Verify Telemetry Deactivation
After setting the variable, open a new terminal window to ensure the change takes effect. Verify that telemetry has been disabled by running:
The output should display
1, confirming that telemetry is now disabled in the .NET Core SDK on Fedora.
To wrap up, this guide has demystified the process of installing the .NET Core SDK on Fedora, showcasing its accessibility and ease of use. Whether you’re opting for the latest version or a specific release, the .NET installer script alongside Linux terminal commands has made the installation straightforward. It’s worth highlighting that the .NET Core SDK is an indispensable asset for .NET developers, offering a comprehensive suite of libraries and tools essential for crafting contemporary applications. The compatibility of .NET with Linux platforms further elevates its value, granting developers the flexibility to create robust and scalable solutions.
For anyone working in the .NET ecosystem, embracing this technology is highly advisable for its significant contributions to efficient and versatile application development.