Installing .NET on Ubuntu
Installing .NET on Ubuntu is supposed to be easy. Sometimes it’s not. You should be able to follow the instructions on the Microsoft docs and install from a package manager but I’ve had issues with that. It’s been a frustrating experience; the package installs but then I can’t run dotnet --version
and I can’t figure out why.
Thankfully there is an option to manually install .NET, this is what I’ve had the most success with.
Here’s a script that I use to install .NET on Ubuntu:
# get the install script
wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
# make it executable
chmod +x ./dotnet-install.sh
# run the script
./dotnet-install.sh
# remove the script
rm ./dotnet-install.sh
# add .dotnet to your path.
# note: im using zsh, if you're using bash you'll need to add this to your .bashrc
echo 'export PATH=$PATH:$HOME/.dotnet' >> ~/.zshrc
# reload your shell
source ~/.zshrc
Now you should be able to run dotnet --version
and see the version of .NET that you installed 🎉