如何修复CentOS上的.Net SDK安装?

kq0g1dla  于 2023-06-22  发布在  .NET
关注(0)|答案(1)|浏览(164)

bounty还有3天到期。回答此问题可获得+250声望奖励。IAbstract希望引起更多关注这个问题。

我已经按照几个地方的说明在CentOS上安装了.Net SDK(Stream Release 9)。

为什么dotnet --info不显示已安装的SDK?

eqzww0vc

eqzww0vc1#

当我试图从这个Microsoft page安装时,我没有成功。
然后我试了这个:
RUN dnf install dotnet-sdk-7.0 -y
在此之后,我运行dotnet --info,输出如下:

[root@ebf572389108 .dotnet]#  dnf install dotnet-sdk-7.0 -y
CentOS Stream 9 - BaseOS                                                                                  5.8 MB/s | 8.4 MB     00:01    
CentOS Stream 9 - AppStream                                                                                12 MB/s |  15 MB     00:01    
CentOS Stream 9 - Extras packages                                                                          16 kB/s |  12 kB     00:00    
Dependencies resolved.
==========================================================================================================================================
 Package                                         Architecture             Version                        Repository                  Size
==========================================================================================================================================
Installing:
 dotnet-sdk-7.0                                  aarch64                  7.0.105-2.el9                  appstream                   83 M
Installing dependencies:
 aspnetcore-runtime-7.0                          aarch64                  7.0.5-2.el9                    appstream                  7.0 M
 aspnetcore-targeting-pack-7.0                   aarch64                  7.0.5-2.el9                    appstream                  1.6 M
 dotnet-apphost-pack-7.0                         aarch64                  7.0.5-2.el9                    appstream                  3.6 M
 dotnet-host                                     aarch64                  7.0.5-2.el9                    appstream                  196 k
 dotnet-hostfxr-7.0                              aarch64                  7.0.5-2.el9                    appstream                  158 k
 dotnet-runtime-7.0                              aarch64                  7.0.5-2.el9                    appstream                   22 M
 dotnet-targeting-pack-7.0                       aarch64                  7.0.5-2.el9                    appstream                  2.7 M
 dotnet-templates-7.0                            aarch64                  7.0.105-2.el9                  appstream                  2.7 M
 libicu                                          aarch64                  67.1-9.el9                     baseos                     9.5 M
 lttng-ust                                       aarch64                  2.12.0-6.el9                   appstream                  288 k
 netstandard-targeting-pack-2.1                  aarch64                  7.0.105-2.el9                  appstream                  1.3 M
 numactl-libs                                    aarch64                  2.0.14-7.el9                   baseos                      30 k
 userspace-rcu                                   aarch64                  0.12.1-6.el9                   baseos                     110 k

Transaction Summary
==========================================================================================================================================
Install  14 Packages

Total download size: 134 M
Installed size: 528 M
Downloading Packages:
(1/14): numactl-libs-2.0.14-7.el9.aarch64.rpm                                                             264 kB/s |  30 kB     00:00    
(2/14): userspace-rcu-0.12.1-6.el9.aarch64.rpm                                                            642 kB/s | 110 kB     00:00    
(3/14): aspnetcore-runtime-7.0-7.0.5-2.el9.aarch64.rpm                                                    8.7 MB/s | 7.0 MB     00:00    
(4/14): aspnetcore-targeting-pack-7.0-7.0.5-2.el9.aarch64.rpm                                             1.7 MB/s | 1.6 MB     00:00    
(5/14): dotnet-host-7.0.5-2.el9.aarch64.rpm                                                               2.9 MB/s | 196 kB     00:00    
(6/14): libicu-67.1-9.el9.aarch64.rpm                                                                     7.8 MB/s | 9.5 MB     00:01    
(7/14): dotnet-hostfxr-7.0-7.0.5-2.el9.aarch64.rpm                                                        2.7 MB/s | 158 kB     00:00    
(8/14): dotnet-apphost-pack-7.0-7.0.5-2.el9.aarch64.rpm                                                   4.3 MB/s | 3.6 MB     00:00    
(9/14): dotnet-runtime-7.0-7.0.5-2.el9.aarch64.rpm                                                         21 MB/s |  22 MB     00:01    
(10/14): dotnet-targeting-pack-7.0-7.0.5-2.el9.aarch64.rpm                                                4.8 MB/s | 2.7 MB     00:00    
(11/14): lttng-ust-2.12.0-6.el9.aarch64.rpm                                                               2.2 MB/s | 288 kB     00:00    
(12/14): netstandard-targeting-pack-2.1-7.0.105-2.el9.aarch64.rpm                                         2.4 MB/s | 1.3 MB     00:00    
(13/14): dotnet-templates-7.0-7.0.105-2.el9.aarch64.rpm                                                   2.2 MB/s | 2.7 MB     00:01    
(14/14): dotnet-sdk-7.0-7.0.105-2.el9.aarch64.rpm                                                          20 MB/s |  83 MB     00:04    
------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                      21 MB/s | 134 MB     00:06     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                  1/1 
  Installing       : dotnet-host-7.0.5-2.el9.aarch64                                                                                 1/14 
  Installing       : aspnetcore-targeting-pack-7.0-7.0.5-2.el9.aarch64                                                               2/14 
  Installing       : dotnet-apphost-pack-7.0-7.0.5-2.el9.aarch64                                                                     3/14 
  Installing       : dotnet-hostfxr-7.0-7.0.5-2.el9.aarch64                                                                          4/14 
  Installing       : dotnet-targeting-pack-7.0-7.0.5-2.el9.aarch64                                                                   5/14 
  Installing       : dotnet-templates-7.0-7.0.105-2.el9.aarch64                                                                      6/14 
  Installing       : netstandard-targeting-pack-2.1-7.0.105-2.el9.aarch64                                                            7/14 
  Installing       : userspace-rcu-0.12.1-6.el9.aarch64                                                                              8/14 
  Installing       : numactl-libs-2.0.14-7.el9.aarch64                                                                               9/14 
  Installing       : lttng-ust-2.12.0-6.el9.aarch64                                                                                 10/14 
  Installing       : libicu-67.1-9.el9.aarch64                                                                                      11/14 
  Installing       : dotnet-runtime-7.0-7.0.5-2.el9.aarch64                                                                         12/14 
  Installing       : aspnetcore-runtime-7.0-7.0.5-2.el9.aarch64                                                                     13/14 
  Installing       : dotnet-sdk-7.0-7.0.105-2.el9.aarch64                                                                           14/14 
  Running scriptlet: dotnet-sdk-7.0-7.0.105-2.el9.aarch64                                                                           14/14 
  Verifying        : libicu-67.1-9.el9.aarch64                                                                                       1/14 
  Verifying        : numactl-libs-2.0.14-7.el9.aarch64                                                                               2/14 
  Verifying        : userspace-rcu-0.12.1-6.el9.aarch64                                                                              3/14 
  Verifying        : aspnetcore-runtime-7.0-7.0.5-2.el9.aarch64                                                                      4/14 
  Verifying        : aspnetcore-targeting-pack-7.0-7.0.5-2.el9.aarch64                                                               5/14 
  Verifying        : dotnet-apphost-pack-7.0-7.0.5-2.el9.aarch64                                                                     6/14 
  Verifying        : dotnet-host-7.0.5-2.el9.aarch64                                                                                 7/14 
  Verifying        : dotnet-hostfxr-7.0-7.0.5-2.el9.aarch64                                                                          8/14 
  Verifying        : dotnet-runtime-7.0-7.0.5-2.el9.aarch64                                                                          9/14 
  Verifying        : dotnet-sdk-7.0-7.0.105-2.el9.aarch64                                                                           10/14 
  Verifying        : dotnet-targeting-pack-7.0-7.0.5-2.el9.aarch64                                                                  11/14 
  Verifying        : dotnet-templates-7.0-7.0.105-2.el9.aarch64                                                                     12/14 
  Verifying        : lttng-ust-2.12.0-6.el9.aarch64                                                                                 13/14 
  Verifying        : netstandard-targeting-pack-2.1-7.0.105-2.el9.aarch64                                                           14/14 

Installed:
  aspnetcore-runtime-7.0-7.0.5-2.el9.aarch64                      aspnetcore-targeting-pack-7.0-7.0.5-2.el9.aarch64                       
  dotnet-apphost-pack-7.0-7.0.5-2.el9.aarch64                     dotnet-host-7.0.5-2.el9.aarch64                                         
  dotnet-hostfxr-7.0-7.0.5-2.el9.aarch64                          dotnet-runtime-7.0-7.0.5-2.el9.aarch64                                  
  dotnet-sdk-7.0-7.0.105-2.el9.aarch64                            dotnet-targeting-pack-7.0-7.0.5-2.el9.aarch64                           
  dotnet-templates-7.0-7.0.105-2.el9.aarch64                      libicu-67.1-9.el9.aarch64                                               
  lttng-ust-2.12.0-6.el9.aarch64                                  netstandard-targeting-pack-2.1-7.0.105-2.el9.aarch64                    
  numactl-libs-2.0.14-7.el9.aarch64                               userspace-rcu-0.12.1-6.el9.aarch64                                      

Complete!

然后与
dotnet --info
我得到了这个(你可以在主机上观察到与你相同的提交Commit:8042 d 61 b17,所以这个版本可能对你有好处)。

[root@ebf572389108 .dotnet]# dotnet --info
.NET SDK:
 Version:   7.0.105
 Commit:    e1bc5e001c

Runtime Environment:
 OS Name:     centos
 OS Version:  9
 OS Platform: Linux
 RID:         centos.9-arm64
 Base Path:   /usr/lib64/dotnet/sdk/7.0.105/

Host:
  Version:      7.0.5
  Architecture: arm64
  Commit:       8042d61b17

.NET SDKs installed:
  7.0.105 [/usr/lib64/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 7.0.5 [/usr/lib64/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 7.0.5 [/usr/lib64/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  DOTNET_ROOT       [//.dotnet]

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

无论如何,我可以猜测,在您的情况下,脚本没有设置正确的路径。
请注意,我的架构是arm 64,与您的AMD 64不同。
但是,您可以尝试上面的dnf命令。

玩转docker

如果你使用docker,你可以尝试在一个容器中安装dotnet(一个新的环境可能会有帮助),像这样:

FROM dokken/centos-stream-9
RUN  dnf install dotnet-sdk-7.0 -y
CMD [ "tail", "-f", "/dev/null" ]

构建图像:
docker build -t centos-dot2 .
运行图像:
docker run --name cent centos-dot2命令后终端将挂起这个终端窗口(因为tail
然后,从另一个终端,在容器中输入:
docker exec -it cent bash
从这里可以运行dotnet --info
最后,当您使用exit退出容器时,停止它并使用以下命令释放:
docker rm -f cent
也许这不是你想要的答案但不管怎样
希望能帮上忙!
Cose贝儿!

相关问题