Rewiring

Installing .NET SDKs without admin nor script access on Windows

A reader contacted me about how to achieve a .NET dev environment without admin access on Windows with the additional hurdle of not having permissions to run scripts. Naturally this makes things a bit more manual, but nonetheless easily achievable.

The key thing that the install script does is building a download url for the SDK based on the parameters given. A final url might be e.g. https://builds.dotnet.microsoft.com/dotnet/Sdk/10.0.101/dotnet-sdk-10.0.101-win-x64.zip

So to do the whole thing manually:

  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. build the download url yourself by substituting the version in the above url with the one you want (see e.g. https://versionsof.net/core/ for a list of current latest versions)
  2. download it directly, smuggle it in via a USB stick... Do whatever you can to get the zip to the local machine
  3. extract the zip to DOTNET_ROOT
  1. restart the terminal and verify installation with dotnet --version

And please note that the installation scripts linked are probably considered 'internal', as is the download url currently used, so they may break at any point. Check the current script definition if this happens.

The original post has consistently been one of my most read, so there clearly is a need for this kind of lightweight SDK management. Hopefully MS will properly support this sooner rather than later, but until then, we'll make do.

Thoughts, comments? Send me an email!

#dotnet #tech