Scott Hanselman

Side by Side user scoped .NET Core installations on Linux with

October 30, 2018 Comment on this post [6] Posted in DotNetCore
Sponsored By

I can run .NET Core on Windows, Mac, or a dozen Linuxes. On my Ubuntu installation I can check what version I have installed and where it is like this:

$ dotnet --version
$ which dotnet

If we interrogate that dotnet file we see it's a link to elsewhere:

$ ls -alogF /usr/bin/dotnet
lrwxrwxrwx 1 22 Sep 19 03:10 /usr/bin/dotnet -> ../share/dotnet/dotnet*

If we head over there we see similar stuff as we do on Windows.

Side by side DotNet installs

Basically c:\program files\dotnet is the same as /share/dotnet.

$ cd ../share/dotnet
$ ll
total 136
drwxr-xr-x 1 root root   4096 Oct  5 19:47 ./
drwxr-xr-x 1 root root   4096 Aug  1 17:44 ../
drwxr-xr-x 1 root root   4096 Feb 13  2018 additionalDeps/
-rwxr-xr-x 1 root root 105704 Sep 19 03:10 dotnet*
drwxr-xr-x 1 root root   4096 Feb 13  2018 host/
-rw-r--r-- 1 root root   1083 Sep 19 03:10 LICENSE.txt
drwxr-xr-x 1 root root   4096 Oct  5 19:48 sdk/
drwxr-xr-x 1 root root   4096 Aug  1 18:07 shared/
drwxr-xr-x 1 root root   4096 Feb 13  2018 store/
-rw-r--r-- 1 root root  27700 Sep 19 03:10 ThirdPartyNotices.txt
$ ls sdk
2.1.4  2.1.403  NuGetFallbackFolder
$ ls shared
Microsoft.AspNetCore.All  Microsoft.AspNetCore.App  Microsoft.NETCore.App
$ ls shared/Microsoft.NETCore.App/
2.0.5  2.1.5

Looking in directories works to figure out what SDKs and Runtime versions are installed, but the best way is to use the dotnet cli itself like this. 

$ dotnet --list-sdks
2.1.4 [/usr/share/dotnet/sdk]
2.1.403 [/usr/share/dotnet/sdk]
$ dotnet --list-runtimes
Microsoft.AspNetCore.All 2.1.5 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.5 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.0.5 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.5 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

There's great instructions on how to set up .NET Core on your Linux machines via Package Manager here.

Note that these installs of the .NET Core SDK are installed in /usr/share. I can use the to do non-admin installs in my own user directory.

In order to gain more control and do things more manually, you can use this shell script here: and its documentation is here at docs. For Windows there is also a PowerShell version

The main usefulness of these scripts is in automation scenarios and non-admin installations. There are two scripts: One is a PowerShell script that works on Windows. The other script is a bash script that works on Linux/macOS. Both scripts have the same behavior. The bash script also reads PowerShell switches, so you can use PowerShell switches with the script on Linux/macOS systems.

For example, I can see all the current .NET Core 2.1 versions at and 2.2 at - the URL format is regular. I can see from that page that at the time of this blog post, v2.1.5 is both Current (most recent stable) and also LTS (Long Term Support).

I'll grab the install script and chmod +x it. Running it with no options will get me the latest LTS release.

$ wget
--2018-10-31 15:41:08--
Resolving (
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 30602 (30K) [application/x-sh]
Saving to: ‘’

I like the "-DryRun" option because it will tell you what WILL happen without doing it.

$ ./ -DryRun
dotnet-install: Payload URL:
dotnet-install: Legacy payload URL:
dotnet-install: Repeatable invocation: ./ --version 2.1.403 --channel LTS --install-dir <auto>

If I use the dotnet-install script can have multiple copies of the .NET Core SDK installed in my user folder at ~/.dotnet. It all depends on your PATH. Note this as I use ~/.dotnet for my .NET Core install location and run dotnet --list-sdks. Make sure you know what your PATH is and that you're getting the .NET Core you expect for your user.

$ which dotnet
$ export PATH=/home/scott/.dotnet:$PATH
$ which dotnet
$ dotnet --list-sdks
2.1.402 [/home/scott/.dotnet/sdk]

Now I will add a few more .NET Core SDKs side-by-side with the script. Remember again, these aren't .NET's installed with apt-get which would be system level and by run with sudo. These are user profile installed versions.

There's really no reason to do side by side at THIS level of granularity, but it makes the point.

$ dotnet --list-sdks
2.1.302 [/home/scott/.dotnet/sdk]
2.1.400 [/home/scott/.dotnet/sdk]
2.1.401 [/home/scott/.dotnet/sdk]
2.1.402 [/home/scott/.dotnet/sdk]
2.1.403 [/home/scott/.dotnet/sdk]

When you're doing your development, you can use "dotnet new globaljson" and have each path/project request a specific SDK version.

$ dotnet new globaljson
The template "global.json file" was created successfully.
$ cat global.json
  "sdk": {
    "version": "2.1.403"

Hope this helps!

Sponsor: Reduce time to market and simplify IOT development using developer kits built on Intel Atom®, Intel® Core™ and Intel® Xeon® processors and tools such as Intel® System Studio and Arduino Create*

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
October 31, 2018 23:34
For some reason this post isn't listed on your front page

This is awesome!

It would be useful to be able install latest version of .Net Core 2, and also remove previously installed .Net Core 2 versions (unless if this breaks something?).
November 01, 2018 1:02
Just thought i'd mention that Chocolatey is reasonably up to date with the SDK's and you can see a full list of whats available with...

choco list dotnetcore-sdk --all-versions

For me, its a little more convenient to install via a package manager rather than navigating to the site and downloading.

November 01, 2018 11:59
Платим за лайки! - Выплаты по требованию!

Наш сервис предоставляет настоящие лайки на фотографии заказчиков, которые готовы платить за качество.

Именно для этого мы и набираем удалённых сотрудников, которые будут выполнять работу, то есть ставить лайки и получить за это деньги.

Чтобы стать нашим удалённым сотрудником и начать ставить лайки, зарабатывая при этом 45 рублей за 1 поставленный лайк,

Вам достаточно просто зарегистрироваться на нашем сервисе.

Ознакомьтесь с правилами и условиями на нашем блоге: > <

Вывод заработанных средств ежедневно в течении нескольких минут.
November 01, 2018 13:12
All I can think about is just having a Powershell Core script as a wrapper for both the Powershell and Bash install scripts.
November 01, 2018 14:02
Can someone recommend some good hands on tutorials/learning resources for .NET Core. It's so different to full fat .NET nowadays I really need to get on it now it's maturing a bit.

I'd like to try converting a ASP.NET MVC 5.2 site to core to see how much benefit I can get out of those speed improvements in the request pipeline that I've seen demonstrated in conference videos I've demonstrated.
November 10, 2018 2:25
Hi Scott. This script has always been a source of frustration for me. I like the option of being able to do a local non-admin install, and I am glad you guys worked to make sure this is possible and easy.

However what I really need is ``

As far as I can tell, side-by-side doesn't work with apt and yum, and the manual installers (including this script) don't setup the enviorment all the way (dotnet tools dont work, nuget caches go to different places, the telementry options and variables are different, etc)

When provisioning produciton hosting servers the apps usually run as virtual/system users without home directories, and as a unique user per app. This script doesn't help with that, and apt/yum don't support multiple versions. We build new images/ami's each week using automation, and having a script that just did the correct thing would be great. Especially considering how often there are new versions of .netcore

When provisioning build servers I need/want the same ability to run any version of dotnet sdk for any user (as root i am installing something that the 'jenkins' user needs available when the process runs under that user).

The number of scenarios where I have multiple human users using the same machine, needing local specific versions of dotnet is non-existent, and a local per-user install is pointless, and the global Linux installers (apt,yum) don't support side by side installs of multiple versions.

We end up building/maintaining our own custom installer scripts, and that is very annoying given that this script already exists, and the fact that the download page (on you guys are so proud of makes it very difficult to even find the proper (post-redirect) download link for each version and component needed.

I feel like this script is great for YOU GUYS. What I mean is, I am sure it is frustrating for you in a demo/conference/workshop to have corporate locked down machines that cant event install the sdk/runtime. But that really isn't a problem faced in the real world.

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.