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
New install is missing some envvars:
https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script?WT.mc_id=dotnet-35129-website#set-environment-variables
echo 'export DOTNET_ROOT=$HOME/.dotnet' >> ~/.bashrc
echo 'export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools' >> ~/.bashrc