- Published on
How to: Install .NET 8.0 (preview version) in your WSL2 instance
Locate to official download page
Download
Linux x64 image
Open your WSL2 instance.
Copy it to your home directory (temporary)
cp /mnt/c/Users/Navus/Downloads/dotnet sdk-8.0.100-rc.2.23502.2-linux-x64.tar.gz .
Create a global directory (if it doesn't exist yet), where you will store all your
dotnet
executables, and extract the downloaded installation.sudo mkdir -p "/usr/local/dotnet" \ && sudo tar zxf dotnet-sdk-8.0.100-rc.2.23502.2-linux-x64.tar.gz -C "/usr/local/dotnet"
Finally, let's add some environment variables.
I highly suggest you to verify if they are not being set already to point to some other place. If they do, then you want to replace them first. Otherwise, just run below
{ echo '' echo '# Setting up .NET SDK environment' echo 'export DOTNET_ROOT=/usr/local/dotnet' echo 'export PATH=$DOTNET_ROOT:$PATH' } >> ~/.zshrc
Use
~/.bashrc
, or~/.profile
if you don't have zsh
Things to know / watch-out:
- Depending on how you installed the dotnet-sdk the first time, the path may change or be different. Sometimes it points to
$HOME/.dotnet
, sometimes to some other place. Always ensure that you pick one and stick with it. It's annoying, but just live with it. which -a dotnet
may help you to find out where yourdotnet
CLI tool is currently sourcing the SDKs from- Ensure your
$PATH
doesn't have multipledotnet
sources. It can cause loads of headaches if it does.
Happy Csharp'ing!