- Published on
How to: Install .NET 8.0 (preview version) in your WSL2 instance
Locate to official download page
Download
Linux x64 imageOpen 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
dotnetexecutables, 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' } >> ~/.zshrcUse
~/.bashrc, or~/.profileif 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 dotnetmay help you to find out where yourdotnetCLI tool is currently sourcing the SDKs from- Ensure your
$PATHdoesn't have multipledotnetsources. It can cause loads of headaches if it does.
Happy Csharp'ing!