Rewiring

Non-admin dotnet dev environment in Windows

Visual Studio is the only IDE I know that requires administrator permissions to install or update. Installing the dotnet SDKs requires admin permissions as well, even when done outside of Visual Studio.

Rider (warmly recommended!) and VSCode are popular alternatives to VS for dotnet work, and neither requires admin access, but what about the SDK?

SDKs without admin

Recently I learned of dotnet-install scripts which allow a non-admin installation of the SDK. While the scripts are intended for CI environments, I've found they work well as the base of a dev environment.

The scripts can be found here. Basically they download the specific SDK files from https://builds.dotnet.microsoft.com/dotnet, e.g. ./dotnet-install.ps1 -Channel LTS -InstallDir C:\cli to install the latest LTS release to the specified directory.

I think I found a good flow for using this now and in the future:

  1. Set the PATH and DOTNET_ROOT environment variables to the directory where you want to store the SDKs
$dotnetPath = "D:\dotnet"
[System.Environment]::SetEnvironmentVariable("DOTNET_ROOT", $dotnetPath, "User")
$currentPath = [System.Environment]::GetEnvironmentVariable("PATH", "User")
if ($currentPath -notlike "*$dotnetPath*") {
    $newPath = $currentPath + ";" + $dotnetPath
    [System.Environment]::SetEnvironmentVariable("PATH", $newPath, "User")
}
  1. (restart the terminal for the environment variable to activate)
  2. Download the dotnet-install.ps1 to the root of that directory Invoke-WebRequest -Uri https://raw.githubusercontent.com/dotnet/install-scripts/refs/heads/main/src/dotnet-install.ps1 -OutFile (Join-Path $Env:DOTNET_ROOT "dotnet-install.ps1")
  3. Call the script to install any version you like ./dotnet-install.ps1 -Channel LTS -InstallDir $Env:DOTNET_ROOT

That's it - all the dotnet SDK versions you could need, installed to where you want them. With the environment variables (PATH is enough) in place, Rider picks up the available versions automatically, and everything Just Works.

Thoughts, comments? Send me an email!

#dotnet #tech #windows