受欢迎的博客标签

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).

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

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:

root@vultr:~/dotnet_install

step 2:

Open a terminal and run the following commands:

root@vultr:~/dotnet_install# curl -H 'Cache-Control: no-cache' -L https://aka.ms/install-dotnet-preview -o install-dotnet-preview.sh

output:

 % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  6356  100  6356    0     0   9067      0 --:--:-- --:--:-- --:--:-- 16682

step 3:Run the script

root@vultr:~/dotnet_install# sudo bash install-dotnet-preview.sh

or

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.

 

root@iZuf6hn15mpmrtypv9ltogZ:~/dotnet_install# pwd
/root/dotnet_install
root@iZuf6hn15mpmrtypv9ltogZ:~/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

 

aliyun

cd dotnet_install

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

 

output:

*** Checking required system dependencies for detected OS: Ubuntu 18.04.4 LTS ...
***     tar is already installed.
***     gzip is already installed.
***     curl is already installed.

*** Setting package type to deb.
*** Download source: dotnet-5.0.0-rc.1-deb.tar.gz

*** Downloading https://dotnetcli.blob.core.windows.net/dotnet/release/install-preview/5.0.0-rc.1/dotnet-5.0.0-rc.1-deb.tar.gz to /root ...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 88.4M  100 88.4M    0     0  20.3M      0  0:00:04  0:00:04 --:--:-- 20.3M

*** Unpacking dotnet-5.0.0-rc.1-deb.tar.gz ...

dotnet_packages/
dotnet_packages/dotnet-host-5.0.0-rc.1.20451.14-x64.deb
dotnet_packages/dotnet-hostfxr-5.0.0-rc.1.20451.14-x64.deb
dotnet_packages/dotnet-targeting-pack-5.0.0-rc.1.20451.14-x64.deb
dotnet_packages/aspnetcore-targeting-pack-5.0.0-rc.1.20451.17.deb
dotnet_packages/dotnet-sdk-5.0.100-rc.1.20452.10-x64.deb
dotnet_packages/._netstandard-targeting-pack-2.1.0-x64.deb
dotnet_packages/netstandard-targeting-pack-2.1.0-x64.deb
dotnet_packages/dotnet-apphost-pack-5.0.0-rc.1.20451.14-x64.deb
dotnet_packages/aspnetcore-runtime-5.0.0-rc.1.20451.17-x64.deb
dotnet_packages/dotnet-runtime-deps-5.0.0-rc.1.20451.14-x64.deb
dotnet_packages/dotnet-runtime-5.0.0-rc.1.20451.14-x64.deb


Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'aspnetcore-runtime-5.0' instead of '/root/dotnet_packages/aspnetcore-runtime-5.0.0-rc.1.20451.17-x64.deb'
Note, selecting 'aspnetcore-targeting-pack-5.0' instead of '/root/dotnet_packages/aspnetcore-targeting-pack-5.0.0-rc.1.20451.17.deb'
Note, selecting 'dotnet-apphost-pack-5.0' instead of '/root/dotnet_packages/dotnet-apphost-pack-5.0.0-rc.1.20451.14-x64.deb'
Note, selecting 'dotnet-host' instead of '/root/dotnet_packages/dotnet-host-5.0.0-rc.1.20451.14-x64.deb'
Note, selecting 'dotnet-hostfxr-5.0' instead of '/root/dotnet_packages/dotnet-hostfxr-5.0.0-rc.1.20451.14-x64.deb'
Note, selecting 'dotnet-runtime-5.0' instead of '/root/dotnet_packages/dotnet-runtime-5.0.0-rc.1.20451.14-x64.deb'
Note, selecting 'dotnet-runtime-deps-5.0' instead of '/root/dotnet_packages/dotnet-runtime-deps-5.0.0-rc.1.20451.14-x64.deb'
Note, selecting 'dotnet-sdk-5.0' instead of '/root/dotnet_packages/dotnet-sdk-5.0.100-rc.1.20452.10-x64.deb'
Note, selecting 'dotnet-targeting-pack-5.0' instead of '/root/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_packages/netstandard-targeting-pack-2.1.0-x64.deb'
netstandard-targeting-pack-2.1 is already the newest version (2.1.0-1).
The following packages will be upgraded:
  aspnetcore-runtime-5.0 aspnetcore-targeting-pack-5.0 dotnet-apphost-pack-5.0 dotnet-host dotnet-hostfxr-5.0 dotnet-runtime-5.0 dotnet-runtime-deps-5.0 dotnet-sdk-5.0 dotnet-targeting-pack-5.0
9 upgraded, 0 newly installed, 0 to remove and 17 not upgraded.
Need to get 0 B/91.3 MB of archives.
After this operation, 19.1 MB of additional disk space will be used.
Get:1 /root/dotnet_packages/dotnet-runtime-deps-5.0.0-rc.1.20451.14-x64.deb dotnet-runtime-deps-5.0 amd64 5.0.0~rc.1.20451.14-1 [2,642 B]
Get:2 /root/dotnet_packages/dotnet-host-5.0.0-rc.1.20451.14-x64.deb dotnet-host amd64 5.0.0~rc.1.20451.14-1 [52.3 kB]
Get:3 /root/dotnet_packages/dotnet-hostfxr-5.0.0-rc.1.20451.14-x64.deb dotnet-hostfxr-5.0 amd64 5.0.0~rc.1.20451.14-1 [141 kB]
Get:4 /root/dotnet_packages/dotnet-runtime-5.0.0-rc.1.20451.14-x64.deb dotnet-runtime-5.0 amd64 5.0.0~rc.1.20451.14-1 [22.0 MB]
Get:5 /root/dotnet_packages/aspnetcore-runtime-5.0.0-rc.1.20451.17-x64.deb aspnetcore-runtime-5.0 amd64 5.0.0~rc.1.20451.17-1 [6,005 kB]
Get:6 /root/dotnet_packages/dotnet-targeting-pack-5.0.0-rc.1.20451.14-x64.deb dotnet-targeting-pack-5.0 amd64 5.0.0~rc.1.20451.14-1 [1,874 kB]
Get:7 /root/dotnet_packages/aspnetcore-targeting-pack-5.0.0-rc.1.20451.17.deb aspnetcore-targeting-pack-5.0 amd64 5.0.0~rc.1.20451.17-1 [1,170 kB]
Get:8 /root/dotnet_packages/dotnet-apphost-pack-5.0.0-rc.1.20451.14-x64.deb dotnet-apphost-pack-5.0 amd64 5.0.0~rc.1.20451.14-1 [3,406 kB]
Get:9 /root/dotnet_packages/dotnet-sdk-5.0.100-rc.1.20452.10-x64.deb dotnet-sdk-5.0 amd64 5.0.100-rc.1.20452.10-1 [56.6 MB]
(Reading database ... 106463 files and directories currently installed.)
Preparing to unpack .../0-dotnet-runtime-deps-5.0.0-rc.1.20451.14-x64.deb ...
Unpacking dotnet-runtime-deps-5.0 (5.0.0~rc.1.20451.14-1) over (5.0.0~preview.4.20251.6-1) ...
Preparing to unpack .../1-dotnet-host-5.0.0-rc.1.20451.14-x64.deb ...
Unpacking dotnet-host (5.0.0~rc.1.20451.14-1) over (5.0.0~preview.4.20251.6-1) ...
Preparing to unpack .../2-dotnet-hostfxr-5.0.0-rc.1.20451.14-x64.deb ...
Unpacking dotnet-hostfxr-5.0 (5.0.0~rc.1.20451.14-1) over (5.0.0~preview.4.20251.6-1) ...
Preparing to unpack .../3-dotnet-runtime-5.0.0-rc.1.20451.14-x64.deb ...
Unpacking dotnet-runtime-5.0 (5.0.0~rc.1.20451.14-1) over (5.0.0~preview.4.20251.6-1) ...
Preparing to unpack .../4-aspnetcore-runtime-5.0.0-rc.1.20451.17-x64.deb ...
Unpacking aspnetcore-runtime-5.0 (5.0.0~rc.1.20451.17-1) over (5.0.0~preview.4.20257.10-1) ...
Preparing to unpack .../5-dotnet-targeting-pack-5.0.0-rc.1.20451.14-x64.deb ...
Unpacking dotnet-targeting-pack-5.0 (5.0.0~rc.1.20451.14-1) over (5.0.0~preview.4.20251.6-1) ...
Preparing to unpack .../6-aspnetcore-targeting-pack-5.0.0-rc.1.20451.17.deb ...
Unpacking aspnetcore-targeting-pack-5.0 (5.0.0~rc.1.20451.17-1) over (5.0.0~preview.4.20257.10-1) ...
Preparing to unpack .../7-dotnet-apphost-pack-5.0.0-rc.1.20451.14-x64.deb ...
Unpacking dotnet-apphost-pack-5.0 (5.0.0~rc.1.20451.14-1) over (5.0.0~preview.4.20251.6-1) ...
Preparing to unpack .../8-dotnet-sdk-5.0.100-rc.1.20452.10-x64.deb ...
Unpacking dotnet-sdk-5.0 (5.0.100-rc.1.20452.10-1) over (5.0.100-preview.4.20258.7-1) ...
Setting up dotnet-host (5.0.0~rc.1.20451.14-1) ...
Setting up dotnet-runtime-deps-5.0 (5.0.0~rc.1.20451.14-1) ...
Setting up dotnet-targeting-pack-5.0 (5.0.0~rc.1.20451.14-1) ...
Setting up aspnetcore-targeting-pack-5.0 (5.0.0~rc.1.20451.17-1) ...
Setting up dotnet-apphost-pack-5.0 (5.0.0~rc.1.20451.14-1) ...
Setting up dotnet-hostfxr-5.0 (5.0.0~rc.1.20451.14-1) ...
Setting up dotnet-runtime-5.0 (5.0.0~rc.1.20451.14-1) ...
Setting up aspnetcore-runtime-5.0 (5.0.0~rc.1.20451.17-1) ...
Setting up dotnet-sdk-5.0 (5.0.100-rc.1.20452.10-1) ...
This software may collect information about you and your use of the software, and send that to Microsoft.
Please visit http://aka.ms/dotnet-cli-eula for more information.
Welcome to .NET!
---------------------
Learn more about .NET: https://aka.ms/dotnet-docs
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs

Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.

Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry

Configuring...
--------------
A command is running to populate your local package cache to improve restore speed and enable offline access. This command takes up to one minute to complete and only runs once.
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
N: Download is performed unsandboxed as root as file '/root/dotnet_packages/dotnet-runtime-deps-5.0.0-rc.1.20451.14-x64.deb' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied)

 

# 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

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