Popular blog tags

In this post we will be installing Microsoft .net  SDK  on Ubuntu Linux and create high performance HTTP end-point in C# on which you can build a micro-service (or anything else).

 

There three choices  install net5.x on OS. see:Install the .NET SDK or the .NET Runtime on Ubuntu

1.Install the .NET SDK or the .NET Runtime with Snap.
2.Install the .NET SDK or the .NET Runtime with a script.
3.Install the .NET SDK or the .NET Runtime manually.

 

https://github.com/dotnet/core/blob/master/release-notes/5.0/5.0.0/5.0.0-install-instructions.md

 

os:Ubuntu 18.04*64

.net 5 version:.net 5.01

.NET 5.0 download url:https://dotnet.microsoft.com/download/dotnet/5.0

                                      https://aka.ms/dotnet-download

You can download .NET 5.0, for Windows, macOS, and Linux, for x86, x64, Arm32, Arm64.

 

Install using deb/rpm packages

step 1:

Create a directory to use for the download location and change into that directory. For example .

# mkdir $HOME/dotnet_install 
cd $HOME/dotnet_install

output:

[email protected]:~/dotnet_install

step 2:get 

Open a terminal and run the following commands:

download come from:

https://dotnet.microsoft.com/download/dotnet/thank-you/sdk-5.0.100-linux-x64-binaries

wget https://download.visualstudio.microsoft.com/download/pr/820db713-c9a5-466e-b72a-16f2f5ed00e2/628aa2a75f6aa270e77f4a83b3742fb8/dotnet-sdk-5.0.100-linux-x64.tar.gz

output:

 Saving to: ‘dotnet-sdk-5.0.100-linux-x64.tar.gz’

step 3:Run the script

tar zxf dotnet-sdk-5.0.100-linux-x64.tar.gz -C /usr/share/dotnet

output

.NET SDK (reflecting any global.json):
 Version:   5.0.100
 Commit:    5044b93829

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  18.04
 OS Platform: Linux
 RID:         ubuntu.18.04-x64
 Base Path:   /usr/share/dotnet/sdk/5.0.100/

Host (useful for support):
  Version: 5.0.0
  Commit:  cf258a14b7

.NET SDKs installed:
  3.0.100 [/usr/share/dotnet/sdk]
  3.1.301 [/usr/share/dotnet/sdk]
  5.0.100-rc.2.20479.15 [/usr/share/dotnet/sdk]
  5.0.100 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.0.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.5 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0-rc.2.20475.17 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.0.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.5 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0-rc.2.20475.5 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

How to check that .NET is already installed


You can see which versions of the .NET SDK are currently installed with a terminal. Open a terminal and run the following command.

Check SDK versions & Check runtime versions

dotnet --list-sdks
dotnet --list-runtimes

output

~/dotnet_install# dotnet --info
.NET SDK (reflecting any global.json):
 Version:   5.0.101
 Commit:    d05174dc5a

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  18.04
 OS Platform: Linux
 RID:         ubuntu.18.04-x64
 Base Path:   /usr/share/dotnet/sdk/5.0.101/

Host (useful for support):
  Version: 5.0.1
  Commit:  b02e13abab

.NET SDKs installed:
  5.0.100 [/usr/share/dotnet/sdk]
  5.0.101 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 5.0.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 5.0.1 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download
root#:~/dotnet_install# dotnet --list-runtimes
Microsoft.AspNetCore.App 5.0.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 5.0.1 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

 

 

aliyun vps

Install using deb/rpm packages on aliyun Ubuntu 18.04*64

aliyun install error

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'aspnetcore-runtime-5.0' instead of '/root/dotnet_install/dotnet_packages/aspnetcore-runtime-5.0.0-rc.1.20451.17-x64.deb'
Note, selecting 'aspnetcore-targeting-pack-5.0' instead of '/root/dotnet_install/dotnet_packages/aspnetcore-targeting-pack-5.0.0-rc.1.20451.17.deb'
Note, selecting 'dotnet-apphost-pack-5.0' instead of '/root/dotnet_install/dotnet_packages/dotnet-apphost-pack-5.0.0-rc.1.20451.14-x64.deb'
Note, selecting 'dotnet-host' instead of '/root/dotnet_install/dotnet_packages/dotnet-host-5.0.0-rc.1.20451.14-x64.deb'
Note, selecting 'dotnet-hostfxr-5.0' instead of '/root/dotnet_install/dotnet_packages/dotnet-hostfxr-5.0.0-rc.1.20451.14-x64.deb'
Note, selecting 'dotnet-runtime-5.0' instead of '/root/dotnet_install/dotnet_packages/dotnet-runtime-5.0.0-rc.1.20451.14-x64.deb'
Note, selecting 'dotnet-runtime-deps-5.0' instead of '/root/dotnet_install/dotnet_packages/dotnet-runtime-deps-5.0.0-rc.1.20451.14-x64.deb'
Note, selecting 'dotnet-sdk-5.0' instead of '/root/dotnet_install/dotnet_packages/dotnet-sdk-5.0.100-rc.1.20452.10-x64.deb'
Note, selecting 'dotnet-targeting-pack-5.0' instead of '/root/dotnet_install/dotnet_packages/dotnet-targeting-pack-5.0.0-rc.1.20451.14-x64.deb'
Note, selecting 'netstandard-targeting-pack-2.1' instead of '/root/dotnet_install/dotnet_packages/netstandard-targeting-pack-2.1.0-x64.deb'
The following packages were automatically installed and are no longer required:
  linux-headers-4.15.0-52 linux-headers-4.15.0-52-generic linux-image-4.15.0-52-generic linux-modules-4.15.0-52-generic linux-modules-extra-4.15.0-52-generic
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  aspnetcore-runtime-5.0 aspnetcore-targeting-pack-5.0 dotnet-apphost-pack-5.0 dotnet-hostfxr-5.0 dotnet-runtime-5.0 dotnet-runtime-deps-5.0 dotnet-sdk-5.0 dotnet-targeting-pack-5.0
The following packages will be upgraded:
  dotnet-host
The following packages will be DOWNGRADED:
  netstandard-targeting-pack-2.1
1 upgraded, 8 newly installed, 1 downgraded, 0 to remove and 205 not upgraded.
E: Packages were downgraded and -y was used without --allow-downgrades.

 

[email protected]:~/dotnet_install# pwd
/root/dotnet_install
[email protected]:~/dotnet_install# ls -l
total 90640
-rw-r--r-- 1 root root  92798272 Sep 16 23:49 dotnet-5.0.0-rc.1-deb.tar.gz
drwxr-xr-x 2  501 staff     4096 Sep 12 07:27 dotnet_packages
-rw-r--r-- 1 root root      6472 Sep 16 19:07 install-dotnet-preview.sh

 

 

 

 

 

instead of

cd dotnet_install

dotnet_install# apt install -y --allow-downgrades ./dotnet_packages/*

 

output:

.NET SDK (reflecting any global.json):
 Version:   5.0.100
 Commit:    5044b93829

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  18.04
 OS Platform: Linux
 RID:         ubuntu.18.04-x64
 Base Path:   /usr/share/dotnet/sdk/5.0.100/

Host (useful for support):
  Version: 5.0.0
  Commit:  cf258a14b7

.NET SDKs installed:
  3.0.100 [/usr/share/dotnet/sdk]
  3.1.301 [/usr/share/dotnet/sdk]
  5.0.100-rc.2.20479.15 [/usr/share/dotnet/sdk]
  5.0.100 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.0.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.5 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0-rc.2.20475.17 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.0.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.5 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0-rc.2.20475.5 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

 

# dotnet --info
.NET SDK (reflecting any global.json):
 Version:   5.0.100-rc.1.20452.10
 Commit:    473d1b592e

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  18.04
 OS Platform: Linux
 RID:         ubuntu.18.04-x64
 Base Path:   /usr/share/dotnet/sdk/5.0.100-rc.1.20452.10/

Host (useful for support):
  Version: 5.0.0-rc.1.20451.14
  Commit:  38017c3935

.NET SDKs installed:
  5.0.100-rc.1.20452.10 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 5.0.0-rc.1.20451.17 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 5.0.0-rc.1.20451.14 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

 

upgrade net5.x on Ubuntu 18.04*64

 

detail:https://docs.microsoft.com/en-us/dotnet/core/install/linux-ubuntu#1804-

step 1:register the Microsoft key

Installing with APT can be done with a few commands. Before you install .NET, run the following commands to add the Microsoft package signing key to your list of trusted keys and add the package repository.

Open a terminal and run the following commands:

wget https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb

step 2: check that .NETx version is already installed

dotnet --info

 

output

.NET SDK (reflecting any global.json):
 Version:   5.0.101
 Commit:    d05174dc5a

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  18.04
 OS Platform: Linux
 RID:         ubuntu.18.04-x64
 Base Path:   /usr/share/dotnet/sdk/5.0.101/

Host (useful for support):
  Version: 5.0.1
  Commit:  b02e13abab

.NET SDKs installed:
  3.0.100 [/usr/share/dotnet/sdk]
  3.1.301 [/usr/share/dotnet/sdk]
  5.0.100 [/usr/share/dotnet/sdk]
  5.0.101 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.0.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.5 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.0.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.5 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.1 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

 

step 3:Install the SDK&Install the runtime

sudo apt-get update; \
  sudo apt-get install -y apt-transport-https && \
  sudo apt-get update && \
  sudo apt-get install -y dotnet-sdk-5.0

sudo apt-get update; \
  sudo apt-get install -y apt-transport-https && \
  sudo apt-get update && \
  sudo apt-get install -y aspnetcore-runtime-5.0

 

 

Here's what the script does.

Detects the distribution and version. If it's in the 5.0 Supported OS list, the script will continue.
Determines if additional system dependencies or utilities are needed to successfully complete and install them. For example tar is used to unpack that installer packages.
Downloads the tar.gz containing the .NET preview installer packages for the detected distribution.
Downloads the system dependency installer, if needed.
Expands the tar.gz into ./dotnet_packages
Attempts to install the contents of ./dotnet_packages using rpm or dpkg, as appropriate, for the detected distribution.

dotnet-runtime-5.0:If only the .NET Core Runtime is needed, install dotnet-runtime-5.0 using your package manager.

aspnetcore-runtime-5.0: If you also need ASP.NET Core functionality, installing aspnetcore-runtime-5.0 will install both the ASP Runtime and .NET Core Runtime.

 

 

https://github.com/dotnet/core/blob/master/release-notes/5.0/preview/5.0.0-rc.1-install-instructions.md

Migrate from ASP.NET Core 3.1 to 5.0

https://docs.microsoft.com/en-us/aspnet/core/migration/31-to-50?view=aspnetcore-3.1&tabs=visual-studio