Downloading .NET for Linux Without Pinning an Obsolete Example

Editorial illustration.

Originally published 21 June 2023; rewritten and reviewed on 15 October 2026.

Back in 2023, the original version of this post had a wget command pointing straight at a .NET Core 3.1 tarball. That worked fine the day I wrote it, and became a liability the moment .NET Core 3.1 hit end-of-life. Hardcoded download URLs age badly—copy one into a Dockerfile or a fresh Ubuntu VPS setup script two years later, and you end up shipping an unsupported runtime without noticing.

When you are provisioning a Linux server over SSH (whether it is a DigitalOcean droplet in Singapore or an on-prem VM), you want a repeatable way to grab the exact .NET package your app targets, verify it, and keep the download step clean.

Pick the right package and architecture first

Before running curl or apt, answer three questions:

  1. SDK or Runtime? On a build server or dev machine where you run dotnet build or dotnet publish, you need the SDK. On a production server running an already-published app, you only need the ASP.NET Core Runtime (for web apps/APIs) or the base .NET Runtime (for console workers). Installing the full SDK on production just wastes disk space.
  2. Which CPU architecture? Most standard x86-64 VPS instances use x64, while AWS Graviton, Ampere, or Raspberry Pi machines use arm64. Check with uname -m (x86_64 maps to x64; aarch64 maps to arm64).
  3. APT package or binary tarball? On Ubuntu 22.04/24.04, sudo apt install dotnet-sdk-8.0 or aspnetcore-runtime-8.0 is often the easiest path if your distro feed carries the LTS version you want. When you need a specific patch version or you are installing inside a minimal container without root, Microsoft’s official dotnet-install.sh script or a direct .tar.gz archive is more predictable.

Option 1: Use Microsoft’s official dotnet-install.sh

If you do not want to hunt down shifting CDN hashes by hand, Microsoft maintains an official installer script that resolves the right channel or exact version for your OS and architecture:

curl -sSL https://dot.net/v1/dotnet-install.sh -o dotnet-install.sh
chmod +x dotnet-install.sh

# Install the latest .NET 8 ASP.NET Core Runtime into ~/.dotnet
./dotnet-install.sh --channel 8.0 --runtime aspnetcore

For a build agent that needs the full SDK pinned to a specific release, swap --runtime aspnetcore for --version 8.0.403 (or whichever exact SDK version your global.json expects).

Option 2: Download and verify the .tar.gz manually

If your server sits in a locked-down environment where you prefer downloading the exact archive and checking its SHA-512 hash yourself, grab the official URL and checksum from Microsoft’s .NET download page for your target release, then keep the download and verification steps separate:

DOTNET_DOWNLOAD_URL="https://download.visualstudio.microsoft.com/download/pr/.../dotnet-sdk-8.0.xxx-linux-x64.tar.gz"
EXPECTED_SHA512="<paste-official-sha512-here>"

curl --fail --location --output dotnet-package.tar.gz "$DOTNET_DOWNLOAD_URL"
echo "$EXPECTED_SHA512  dotnet-package.tar.gz" | sha512sum -c -

Using curl --fail ensures that a 404 or proxy error page does not get saved silently as dotnet-package.tar.gz, and quoting "$DOTNET_DOWNLOAD_URL" prevents shell word-splitting.

Only after sha512sum -c - prints OK should you extract the archive:

mkdir -p "$HOME/.dotnet"
tar -zxf dotnet-package.tar.gz -C "$HOME/.dotnet"

Then export DOTNET_ROOT and update PATH in ~/.bashrc or ~/.zshrc (or /etc/profile.d/dotnet.sh for system-wide installs):

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

Confirm what the host actually resolves

Never assume the shell picked up the new binary—especially if an older distro package already lived in /usr/bin/dotnet. Run:

which dotnet
dotnet --info
dotnet --list-runtimes

Check that the path, architecture, and runtime version match what your .csproj targets. If you are building from source, commit a global.json at the root of the repository so dotnet build tells you immediately when a machine has the wrong SDK installed instead of silently rolling forward to an unexpected major version.