Last active
August 20, 2025 17:36
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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