If you’re using Debian 12 and need to run or develop applications built with .NET Core 3.1, you can easily set up the runtime and SDK environments using Snap. Here’s a step-by-step guide to get you started:
Step 1: Install Snap
Snap is a package management system that makes it easy to install and manage software. First, ensure Snap is installed and enabled on your system:
1 2 3 4 5 |
sudo apt update sudo apt install snapd -y sudo snap install core sudo systemctl enable --now snapd.socket sudo ln -s /var/lib/snapd/snap /snap |
This installs Snap and ensures that it starts automatically.
Step 2: Install .NET Core 3.1 Runtime
With Snap installed, you can now install the .NET Core 3.1 runtime. Run the following command:
1 |
sudo snap install dotnet-runtime-31 --classic |
The --classic
flag ensures that the runtime has the necessary permissions to function correctly.
Step 3: Install .NET Core 3.1 SDK
To develop applications with .NET Core 3.1, you also need to install the SDK. Use the following command:
1 |
sudo snap install dotnet-sdk --classic --channel=3.1/stable |
The SDK includes tools to create, build, and debug .NET applications.
Step 4: Verify the Installation
Once the runtime and SDK are installed, verify that they are working by listing the installed .NET runtimes and SDKs:
1 2 |
dotnet --list-runtimes dotnet --list-sdks |
You should see entries for Microsoft.NETCore.App 3.1.x in the runtimes and 3.1.x in the SDKs.
Step 5: Test the Runtime and SDK
To confirm the runtime and SDK are fully functional, create and run a simple .NET application:
- Create a Test Directory
1 |
mkdir dotnet-test && cd dotnet-test |
- Create a New Console Application
1 2 |
dotnet new console -n TestApp cd TestApp |
- Run the Program
1 |
dotnet run |
If everything is set up correctly, you’ll see:
1 |
Hello, World! |
Important Notes
- End of Support:
.NET Core 3.1 reached its end of support on December 13, 2022. It’s recommended to upgrade to a newer version of .NET if possible. - Snap Isolation:
Snap installs software in isolated environments. If your application requires additional configuration, ensure it’s compatible with Snap’s sandboxing. - Upgrade Recommendation:
While .NET Core 3.1 may be sufficient for legacy applications, exploring .NET 6 or later versions can offer long-term support and better performance.
With these steps, you can quickly get your .NET Core 3.1 runtime and SDK environments ready on Debian 12.