Skip to content

Instantly share code, notes, and snippets.

@breiter
Last active June 17, 2020 11:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save breiter/aef0c0acbeb24cabe0fa16c7ecfdb88c to your computer and use it in GitHub Desktop.
Save breiter/aef0c0acbeb24cabe0fa16c7ecfdb88c to your computer and use it in GitHub Desktop.
Script to maintain dontet core SDK with the current latest LTS versions
#!/bin/sh
# Get the MSFT uninstall script from GitHub:
#
# curl -sSL https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/uninstall/dotnet-uninstall-pkgs.sh | sudo tee /usr/local/bin/dotnet-uninstall-pkgs > /dev/null
# sudo chmod +x /usr/local/bin/dotnet-uninstall-pkgs
#
uninstall_cmd=dotnet-uninstall-pkgs
# MSFT install script documented on docs.microsoft.com
# https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script
#
# curl -sSL https://dot.net/v1/dotnet-install.sh | sudo tee /usr/local/bin/dotnet-install > /dev/null
# chmod +x /usr/local/bin/dotnet-install
#
install_cmd=dotnet-install
# also set within dotnet-uninstall-pkgs.sh
dotnet_install_root="/usr/local/share/dotnet"
dotnet_path_file="/etc/paths.d/dotnet"
dotnet_tool_path_file="/etc/paths.d/dotnet-cli-tools"
current_userid=$(id -u)
if [ $current_userid -ne 0 ]; then
echo "$(basename "$0") requires superuser privileges to run" >&2
exit 1
fi
${uninstall_cmd}
${install_cmd} --install-dir ${dotnet_install_root} --no-path --channel 2.1 # old LTS Channel
${install_cmd} --install-dir ${dotnet_install_root} --no-path --channel LTS # current LTS Channel
echo adding dotnet and tools to path.
# created by pkg installers but not the install script
echo ${dotnet_install_root} > ${dotnet_path_file}
echo "~/.dotnet/tools" > ${dotnet_tool_path_file}
eval $(/usr/libexec/path_helper -s)
@breiter
Copy link
Author

breiter commented Jun 17, 2020

Set up.

curl -sSL https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/uninstall/dotnet-uninstall-pkgs.sh | sudo tee /usr/local/bin/dotnet-uninstall-pkgs > /dev/null
sudo chmod +x /usr/local/bin/dotnet-uninstall-pkgs
curl -sSL https://dot.net/v1/dotnet-install.sh | sudo tee /usr/local/bin/dotnet-install > /dev/null
chmod +x /usr/local/bin/dotnet-install
curl -sSL https://gist.github.com/breiter/aef0c0acbeb24cabe0fa16c7ecfdb88c/raw/b4e9de4b20141b0a05aadd03d5842752104b1475/dotnet-upgrade-sdks.sh  | sudo tee /usr/local/bin/dotnet-upgrade-sdks > /dev/null
chmod +x  /usr/local/bin/dotnet-upgrade-sdks 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment