Skip to content

Instantly share code, notes, and snippets.

@breiter
Last active August 20, 2025 17:36
Show Gist options
  • Select an option

  • Save breiter/72c189408ede9f43ff5158172b68673e to your computer and use it in GitHub Desktop.

Select an option

Save breiter/72c189408ede9f43ff5158172b68673e to your computer and use it in GitHub Desktop.
Install the latest dotnet LTS and STS SDK and remove the old ones
#!/usr/bin/env bash
dotnet_root=$HOME/.dotnet
# installs dotnet sdk in a non-admin path
# requires shell config to work
# FOR EXAMPLE in ~/.zshenv
#
# #dotnet
# export DOTNET_ROOT="$HOME/.dotnet"
#
# # dotnet core global tools
# # check for /etc/paths.d/dotnet and /etc/paths.d/dotnet-cli-tools
# export PATH="$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools"
# # disable dotnet sdk telemetry
# # https://learn.microsoft.com/en-us/dotnet/core/tools/telemetry#how-to-opt-out
# export DOTNET_CLI_TELEMETRY_OPTOUT=true
echo "Removing old dotnet runtimes and sdks."
declare -a dirs=(host metadata templates sdk sdk-manifests shares packs)
for d in "${dirs[@]}";
do
rm -fr "${dotnet_root:?}/${d}"
done
rm "${dotnet_root:?}/dotnet"
echo ""
echo "Installing dotnet LTS sdk."
curl -LsSf https://dot.net/v1/dotnet-install.sh|bash /dev/stdin --channel LTS
echo ""
echo "Installing dotnet STS sdk."
curl -LsSf https://dot.net/v1/dotnet-install.sh|bash /dev/stdin --channel STS
echo ""
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment