ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

【学习笔记】在 CentOS 7 上部署 .NET 环境

2022-01-08 02:32:14  阅读:222  来源: 互联网

标签:11 x86 CentOS 笔记 64 6.0 dotnet NET pack


1、部署环境说明

操作系统:CentOS 7

系统版本:3.10.0-1160.el7.x86_64

备注说明:本次演练基于 VMware® Workstation 16 Pro 安装 CentOS 7 虚拟机,安装时选择最小安装模式。

2、注册镜像地址

从微软官方网址 https://packages.microsoft.com/config/ 查询针对 CentOS 7 的配置文件,把文件路径复制下来,执行以下命令。

 sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
[root@localhost ~]# sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
获取https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
准备中...                              ################################# [100%]
正在升级/安装...
   1:packages-microsoft-prod-1.0-1    ################################# [100%]
[root@localhost ~]#

3、执行 yum 更新

在进行 .NET SDK 安装之前,最好先把系统更新一下,保障运行环境为最新版本。

sudo yum update

# 以下为输出结果,显示系统已是最新~
[root@localhost ~]# sudo yum update
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.dgut.edu.cn
 * extras: mirrors.dgut.edu.cn
 * updates: mirrors.163.com
No packages marked for update
[root@localhost ~]#

PS:直接使用官网镜像仓库可能会比较慢,可以给系统配置一下加速镜像地址。具体方法可以看我的其他文章或自行百度。

4、搜索安装包

查询当前支持的 sdk 版本。

[root@localhost ~]# yum search all  dotnet-sdk
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.dgut.edu.cn
 * extras: mirrors.dgut.edu.cn
 * updates: mirrors.163.com
=================== 匹配:dotnet-sdk ===================
dotnet-sdk-2.1.x86_64 : Microsoft .NET Core SDK 2.1.818 2.1.818
dotnet-sdk-2.2.x86_64 : Microsoft .NET Core SDK 2.2.402 2.2.402
dotnet-sdk-3.0.x86_64 : Microsoft .NET Core SDK 3.0.103 3.0.103
dotnet-sdk-3.1.x86_64 : Microsoft .NET Core SDK 3.1.416 3.1.416
dotnet-sdk-5.0.x86_64 : Microsoft .NET SDK 5.0.404 5.0.404
dotnet-sdk-6.0.x86_64 : Microsoft .NET SDK 6.0.101 6.0.101
[root@localhost ~]#

5、安装 dotnet-sdk

安装 SDK,通过以下安装过程可以看出,在安装 SDK 的同时,dotnet-runtime 作为依赖项,也被同时安装了。

yum install dotnet-sdk-6.0

安装过程如下:

[root@localhost ~]# yum install dotnet-sdk-6.0
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.dgut.edu.cn
 * extras: mirrors.dgut.edu.cn
 * updates: mirrors.163.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 dotnet-sdk-6.0.x86_64.0.6.0.101-1 将被 安装
--> 正在处理依赖关系 netstandard-targeting-pack-2.1 >= 2.1.0,它被软件包 dotnet-sdk-6.0-6.0.101-1.x86_64 需要
--> 正在处理依赖关系 dotnet-runtime-6.0,它被软件包 dotnet-sdk-6.0-6.0.101-1.x86_64 需要
--> 正在处理依赖关系 dotnet-targeting-pack-6.0,它被软件包 dotnet-sdk-6.0-6.0.101-1.x86_64 需要
--> 正在处理依赖关系 dotnet-apphost-pack-6.0,它被软件包 dotnet-sdk-6.0-6.0.101-1.x86_64 需要
--> 正在处理依赖关系 aspnetcore-runtime-6.0,它被软件包 dotnet-sdk-6.0-6.0.101-1.x86_64 需要
--> 正在处理依赖关系 aspnetcore-targeting-pack-6.0,它被软件包 dotnet-sdk-6.0-6.0.101-1.x86_64 需要
--> 正在检查事务
---> 软件包 aspnetcore-runtime-6.0.x86_64.0.6.0.1-1 将被 安装
---> 软件包 aspnetcore-targeting-pack-6.0.x86_64.0.6.0.0-1 将被 安装
---> 软件包 dotnet-apphost-pack-6.0.x86_64.0.6.0.1-1 将被 安装
---> 软件包 dotnet-runtime-6.0.x86_64.0.6.0.1-1 将被 安装
--> 正在处理依赖关系 dotnet-hostfxr-6.0 >= 6.0.1,它被软件包 dotnet-runtime-6.0-6.0.1-1.x86_64 需要
--> 正在处理依赖关系 dotnet-runtime-deps-6.0 >= 6.0.1,它被软件包 dotnet-runtime-6.0-6.0.1-1.x86_64 需要
---> 软件包 dotnet-targeting-pack-6.0.x86_64.0.6.0.1-1 将被 安装
---> 软件包 netstandard-targeting-pack-2.1.x86_64.0.2.1.0-1 将被 安装
--> 正在检查事务
---> 软件包 dotnet-hostfxr-6.0.x86_64.0.6.0.1-1 将被 安装
--> 正在处理依赖关系 dotnet-host >= 6.0.1,它被软件包 dotnet-hostfxr-6.0-6.0.1-1.x86_64 需要
---> 软件包 dotnet-runtime-deps-6.0.x86_64.0.6.0.1-1 将被 安装
--> 正在处理依赖关系 libicu,它被软件包 dotnet-runtime-deps-6.0-6.0.1-1.x86_64 需要
--> 正在检查事务
---> 软件包 dotnet-host.x86_64.0.6.0.1-1 将被 安装
---> 软件包 libicu.x86_64.0.50.2-4.el7_7 将被 安装
--> 解决依赖关系完成

依赖关系解决

================================================================================================
 Package                           架构       版本          源                              大小
================================================================================================
正在安装:
 dotnet-sdk-6.0                   x86_64     6.0.101-1     packages-microsoft-com-prod    114 M
为依赖而安装:
 aspnetcore-runtime-6.0           x86_64     6.0.1-1       packages-microsoft-com-prod    8.7 M
 aspnetcore-targeting-pack-6.0    x86_64     6.0.0-1       packages-microsoft-com-prod    2.0 M
 dotnet-apphost-pack-6.0          x86_64     6.0.1-1       packages-microsoft-com-prod    4.7 M
 dotnet-host                      x86_64     6.0.1-1       packages-microsoft-com-prod     67 k
 dotnet-hostfxr-6.0               x86_64     6.0.1-1       packages-microsoft-com-prod    173 k
 dotnet-runtime-6.0               x86_64     6.0.1-1       packages-microsoft-com-prod     29 M
 dotnet-runtime-deps-6.0          x86_64     6.0.1-1       packages-microsoft-com-prod    3.9 k
 dotnet-targeting-pack-6.0        x86_64     6.0.1-1       packages-microsoft-com-prod    3.1 M
 libicu                           x86_64     50.2-4.el7_7  base                           6.9 M
 netstandard-targeting-pack-2.1   x86_64     2.1.0-1       packages-microsoft-com-prod    2.1 M

事务概要
=================================================================================================
安装  1 软件包 (+10 依赖软件包)

总下载量:171 M
安装大小:483 M
Is this ok [y/d/N]: y

Downloading packages:
警告:/var/cache/yum/x86_64/7/packages-microsoft-com-prod/packa | 9.9 MB  00:04:18 ETA
ges/aspnetcore-runtime-6.0.1-x64.rpm: 头V4 RSA/SHA256 Signature,
密钥 ID be1229cf: NOKEYB/saspnetcore-runtime-6.0.1-x64.rpm 的公钥
尚未安装
(1/11): aspnetcore-runtime-6.0.1-x64.rpm                       | 8.7 MB  00:00:16
(2/11): aspnetcore-targeting-pack-6.0.0.rpm                    | 2.0 MB  00:00:27
(3/11): dotnet-apphost-pack-6.0.1-x64.rpm                      | 4.7 MB  00:00:10
(4/11): dotnet-host-6.0.1-x64.rpm                              |  67 kB  00:00:00
(5/11): dotnet-hostfxr-6.0.1-x64.rpm                           | 173 kB  00:00:00
(6/11): dotnet-runtime-deps-6.0.1-centos.7-x64.rpm             | 3.9 kB  00:00:00
(7/11): dotnet-runtime-6.0.1-x64.rpm  13% [========-] 634 kB/s |  23 MB
(7/11): dotnet-sdk-6.0.101-x64.rpm                             | 114 MB  00:03:36
(8/11): libicu-50.2-4.el7_7.x86_64.rpm                         | 6.9 MB  00:00:01
(9/11): dotnet-targeting-pack-6.0.1-x64.rpm                    | 3.1 MB  00:00:05
(10/11): netstandard-targeting-pack-2.1.0-x64.rpm              | 2.1 MB  00:00:05
(11/11): dotnet-runtime-6.0.1-x64.rpm                          |  29 MB  00:06:20
----------------------------------------------------------------------------------------------------
总计                                                   429 kB/s | 171 MB  00:06:48
从 https://packages.microsoft.com/keys/microsoft.asc 检索密钥
导入 GPG key 0xBE1229CF:
 用户ID     : "Microsoft (Release signing) <gpgsecurity@microsoft.com>"
 指纹       : bc52 8686 b50d 79e3 39d3 721c eb3e 94ad be12 29cf
 来自       : https://packages.microsoft.com/keys/microsoft.asc
是否继续?[y/N]:y

Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 数据库已被非 yum 程序修改。
  正在安装    : dotnet-targeting-pack-6.0-6.0.1-1.x86_64                1/11
  正在安装    : aspnetcore-targeting-pack-6.0-6.0.0-1.x86_64            2/11
  正在安装    : dotnet-apphost-pack-6.0-6.0.1-1.x86_64                  3/11
  正在安装    : libicu-50.2-4.el7_7.x86_64                              4/11
  正在安装    : dotnet-runtime-deps-6.0-6.0.1-1.x86_64                  5/11
  正在安装    : netstandard-targeting-pack-2.1-2.1.0-1.x86_64           6/11
  正在安装    : dotnet-host-6.0.1-1.x86_64                              7/11
  正在安装    : dotnet-hostfxr-6.0-6.0.1-1.x86_64                       8/11
  正在安装    : dotnet-runtime-6.0-6.0.1-1.x86_64                       9/11
  正在安装    : aspnetcore-runtime-6.0-6.0.1-1.x86_64                  10/11
  正在安装    : dotnet-sdk-6.0-6.0.101-1.x86_64                        11/11
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.
  验证中      : aspnetcore-runtime-6.0-6.0.1-1.x86_64                   1/11
  验证中      : dotnet-host-6.0.1-1.x86_64                              2/11
  验证中      : dotnet-runtime-deps-6.0-6.0.1-1.x86_64                  3/11
  验证中      : netstandard-targeting-pack-2.1-2.1.0-1.x86_64           4/11
  验证中      : libicu-50.2-4.el7_7.x86_64                              5/11
  验证中      : dotnet-targeting-pack-6.0-6.0.1-1.x86_64                6/11
  验证中      : dotnet-sdk-6.0-6.0.101-1.x86_64                         7/11
  验证中      : dotnet-apphost-pack-6.0-6.0.1-1.x86_64                  8/11
  验证中      : aspnetcore-targeting-pack-6.0-6.0.0-1.x86_64            9/11
  验证中      : dotnet-hostfxr-6.0-6.0.1-1.x86_64                      10/11
  验证中      : dotnet-runtime-6.0-6.0.1-1.x86_64                      11/11

已安装:
  dotnet-sdk-6.0.x86_64 0:6.0.101-1

作为依赖被安装:
  aspnetcore-runtime-6.0.x86_64 0:6.0.1-1 
  aspnetcore-targeting-pack-6.0.x86_64 0:6.0.0-1 
  dotnet-apphost-pack-6.0.x86_64 0:6.0.1-1   
  dotnet-host.x86_64 0:6.0.1-1 
  dotnet-hostfxr-6.0.x86_64 0:6.0.1-1
  dotnet-runtime-6.0.x86_64 0:6.0.1-1     
  dotnet-runtime-deps-6.0.x86_64 0:6.0.1-1       
  dotnet-targeting-pack-6.0.x86_64 0:6.0.1-1 
  libicu.x86_64 0:50.2-4.el7_7 
  netstandard-targeting-pack-2.1.x86_64 0:2.1.0-1

完毕!
[root@localhost ~]#

6、验证是否成功

[root@localhost ~]# dotnet --version
6.0.101

也可以执行其他命令进行验证。


[root@localhost ~]# dotnet new
“dotnet new”命令基于模板创建 .NET 项目。

常用模板包括:
模板名                   短名称           语言          标记
--------------------  ------------  ----------  -------------------
ASP.NET Core Web App  webapp,razor  [C#]        Web/MVC/Razor Pages
Blazor Server App     blazorserver  [C#]        Web/Blazor
Console Application   console       [C#],F#,VB  Common/Console
Class library         classlib      [C#],F#,VB  Common/Library

例如:
   dotnet new console

通过以下方式显示模板选项:
   dotnet new console -h
通过以下方式显示已安装的所有模板:
   dotnet new --list
通过以下方式显示 NuGet.org 上可用模板:
   dotnet new web --search

[root@localhost ~]# dotnet --version
6.0.101
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# dotnet new
“dotnet new”命令基于模板创建 .NET 项目。

常用模板包括:
模板名                   短名称           语言          标记
--------------------  ------------  ----------  -------------------
ASP.NET Core Web App  webapp,razor  [C#]        Web/MVC/Razor Pages
Blazor Server App     blazorserver  [C#]        Web/Blazor
Console Application   console       [C#],F#,VB  Common/Console
Class library         classlib      [C#],F#,VB  Common/Library

例如:
   dotnet new console

通过以下方式显示模板选项:
   dotnet new console -h
通过以下方式显示已安装的所有模板:
   dotnet new --list
通过以下方式显示 NuGet.org 上可用模板:
   dotnet new web --search

[root@localhost ~]#

标签:11,x86,CentOS,笔记,64,6.0,dotnet,NET,pack
来源: https://www.cnblogs.com/lihengsun/p/15777366.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有