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 2.1.403 $ which dotnet /usr/bin/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.
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 dotnet-install.sh 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: https://dot.net/v1/dotnet-install.sh and its documentation is here at docs. For Windows there is also a PowerShell version https://dot.net/v1/dotnet-install.ps1
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 https://www.microsoft.com/net/download/dotnet-core/2.1 and 2.2 at https://www.microsoft.com/net/download/dotnet-core/2.2 - 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 https://dot.net/v1/dotnet-install.sh --2018-10-31 15:41:08-- https://dot.net/v1/dotnet-install.sh Resolving dot.net (dot.net)... 104.214.64.238 Connecting to dot.net (dot.net)|104.214.64.238|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 30602 (30K) [application/x-sh] Saving to: ‘dotnet-install.sh’
I like the "-DryRun" option because it will tell you what WILL happen without doing it.
$ ./dotnet-install.sh -DryRun dotnet-install: Payload URL: https://dotnetcli.azureedge.net/dotnet/Sdk/2.1.403/dotnet-sdk-2.1.403-linux-x64.tar.gz dotnet-install: Legacy payload URL: https://dotnetcli.azureedge.net/dotnet/Sdk/2.1.403/dotnet-dev-ubuntu.16.04-x64.2.1.403.tar.gz dotnet-install: Repeatable invocation: ./dotnet-install.sh --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 /usr/bin/dotnet $ export PATH=/home/scott/.dotnet:$PATH $ which dotnet /home/scott/.dotnet/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 dotnet-install.sh 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*
© 2018 Scott Hanselman. All rights reserved.
from Scott Hanselman's Blog http://feeds.hanselman.com/~/577713230/0/scotthanselman~Side-by-Side-user-scoped-NET-Core-installations-on-Linux-with-dotnetinstallsh.aspx
Comments
Post a Comment