Install .NET via the following script:
I advise to first do a dry run and to enable verbose mode to review if envvar DOTNET_INSTALL_DIR
is set correctly:
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --version latest --verbose --dry-run
Note: Preview must include the full preview release label like 8.0.100-rc.1.23463.5
Inspect the output and validate the install path. You can override this as listed in the script its help:
export DOTNET_INSTALL_DIR=/opt/dotnet
I already had older SDK's installed in /opt/dotnet
but the script will not add new SDK's to that path automatically although the DOTNET_ROOT
envvar already points to this path.
Run the script but now without --dry-run
:
Latest
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --version latest --verbose
Review the SDK's after installation:
dotnet --list-sdks
You can easily remove SDK's by removing the corresponding folders:
sudo -s
cd DOTNET_INSTALL_DIR
rm -r sdk/$version
rm -r shared/Microsoft.NETCore.App/$version
rm -r shared/Microsoft.AspNetCore.All/$version
rm -r shared/Microsoft.AspNetCore.App/$version
rm -r host/fxr/$version
To install .NET 9.0 (or newer), simply append
--channel STS
to the install command.For example, I've installed with:
curl -sSL https://dot.net/v1/dotnet-install.sh | sudo bash /dev/stdin \ --version latest \ --verbose \ --install-dir /opt/dotnet \ --channel STS
STS = Standard term Support Release, default is LTS (Long Term Support Release)