Skip to content

Instantly share code, notes, and snippets.

@andrewodri
Last active December 7, 2024 03:15
Show Gist options
  • Save andrewodri/9fdf9d7ed2de86566897dbc4e174a0df to your computer and use it in GitHub Desktop.
Save andrewodri/9fdf9d7ed2de86566897dbc4e174a0df to your computer and use it in GitHub Desktop.
Install .NET SDK 5.0 on macOS one-liner

Based on the official Microsoft documentation with a bit of sketchiness added in for convenience:

echo -ne "\033[0;31mdotnet-install:\033[0m Enter the .NET Core SDK channel (i.e. n.n, not n.n.n) you would like to install: " && read CHANNEL; curl -sSL https://dot.net/v1/dotnet-install.sh | bash -s -- --channel "${CHANNEL}" && grep -qxF 'export PATH=$PATH:$HOME/.dotnet' ~/.zshrc || echo 'export PATH=$PATH:$HOME/.dotnet' >> ~/.zshrc && source ~/.zshrc

This does the following:

  • Prompt the user to enter a .NET Core SDK version to install
  • Install the entered .NET Core SDK version
  • Add the dotnet path to ~/.zshrc file so that you can actually use it
  • Source the ~/.zshrc file so you can start using it

Just run dotnet --info to make sure everything is goo, and you be ready to rock!

Note: You may need to replace the --channel n.n switch with --version n.n.n if you want to install a specific version of the SDK.

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