Dotnet SDK Version Management
From Logic Wiki
Contents
check existing SDKs
dotnet --list-sdks
install dotnetup
https://devblogs.microsoft.com/dotnet/introducing-dotnetup/
macOS (Zsh):
curl -fsSL https://aka.ms/dotnetup/get-dotnetup.sh | zsh
Linux (Bash):
curl -fsSL https://aka.ms/dotnetup/get-dotnetup.sh | bash
PowerShell (pwsh):
irm https://aka.ms/dotnetup/get-dotnetup.ps1 | iex
Once the script pulls down the binary, initialize your environment:
Usage
dotnetup init
The init command sets up your shell profile so that dotnet is immediately available in your terminal sessions and fetches the latest stable .NET SDK.
Env variables
Fix it by putting that folder first on PATH. For the current session:
$env:DOTNET_ROOT = "$env:LOCALAPPDATA\dotnetup\dotnet"
$env:PATH = "$env:DOTNET_ROOT;$env:PATH"
dotnet --version # should report 10.0.404
To make it permanent:
[Environment]::SetEnvironmentVariable('DOTNET_ROOT', "$env:LOCALAPPDATA\dotnetup\dotnet", 'User')
[Environment]::SetEnvironmentVariable('PATH', "$env:LOCALAPPDATA\dotnetup\dotnet;" + [Environment]::GetEnvironmentVariable('PATH','User'), 'User')