CentOS离线安装DotNetcoreSDK6

客户的服务器环境基本是不能联网的,因此yum安装是不行的,程序依赖的dotnet的SDK需要下载离线包安装。

先从微软官网下载包:
官网地址

CentOS离线安装DotNetcoreSDK6_第1张图片

下载后把dotnet-sdk-6.0.408-linux-x64.tar.gz上传到/lis/dotnet目录
CentOS离线安装DotNetcoreSDK6_第2张图片
解压-拷贝-创建软链接

cd /lis/dotnet
tar -xvf dotnet-sdk-6.0.408-linux-x64.tar.gz
cd ..
cp -rf dotnet /etc
ln -s /etc/dotnet/dotnet /usr/bin/dotnet
chmod +x /usr/bin/dotnet

测试

[root@localhost lis]# dotnet

Usage: dotnet [options]
Usage: dotnet [path-to-application]

Options:
  -h|--help         Display help.
  --info            Display .NET information.
  --list-sdks       Display the installed SDKs.
  --list-runtimes   Display the installed runtimes.

path-to-application:
  The path to an application .dll file to execute.
[root@localhost lis]# dotnet --info
.NET SDK:
 Version:   6.0.408
 Commit:    0c3669d367

运行时环境:
 OS Name:     centos
 OS Version:  7
 OS Platform: Linux
 RID:         centos.7-x64
 Base Path:   /etc/dotnet/sdk/6.0.408/

global.json file:
  Not found

Host:
  Version:      6.0.16
  Architecture: x64
  Commit:       1e620a42e7

.NET SDKs installed:
  6.0.408 [/etc/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.16 [/etc/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.16 [/etc/dotnet/shared/Microsoft.NETCore.App]

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

Learn about .NET Runtimes and SDKs:
  https://aka.ms/dotnet/runtimes-sdk-info
[root@localhost lis]# 

这样就把dotnetsdk离线安装好了。

原理就是离线包本身是完整的程序体,解压直接运行里面的dotnet文件就行。解压后先拷贝到要放的目录,然后给usr/bin下创建个软连接指向包里的dotnet,这样运行dotnet命令就能在usr/bin下找到了,否则就敲全路径运行也可以。

你可能感兴趣的:(DotNetCore,centos,linux,服务器)