赞
踩
添加仓储指令
rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
执⾏安装命令:
1、如果不需要在linux上编译源码
yum install dotnet-runtime-6.0
2、如果需要在linux上编译源码
yum install dotnet-sdk-6.0
3、如果是有webapi接⼝或者⽹页
yum install aspnetcore-runtime-6.0
安装完成后输⼊指令
dotnet --info 查看是否安装正确
Centos7中安装Net5.0运⾏时,只需要把6.0替换为5.0
去微软官网找到下载链接Download .NET 6.0 (Linux, macOS, and Windows)https://dotnet.microsoft.com/en-us/download/dotnet/6.0
- sudo mkdir dotnet
- sudo tar zxvf dotnet-sdk-6.0.101-linux-x64.tar.gz -C dotnet
修改环境变量
vi /etc/profile
在文件尾部添加
- export PATH=$PATH:/data/dotnet
- export DOTNET_ROOT=/data/dotnet
测试dotnet --info
判断运行环境是不是windows
- bool isWindows = System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
- string filePath = string.Empty;
- if (isWindows)
- {
- filePath = "c:/" + name;
- }
- else
- {
- filePath = "/" + name;
- }
dotnet 程序名.dll
出现以下信息,是因为没有装aspnetcore的运行时,运行yum install aspnetcore-runtime-6.0即可
- It was not possible to find any compatible framework version
- The framework 'Microsoft.AspNetCore.App', version '6.0.0' (x64) was not found.
- - No frameworks were found.
-
- You can resolve the problem by installing the specified framework and/or SDK.
-
- The specified framework can be found at:
- - https://aka.ms/dotnet-core-applaunch?framework=Microsoft.AspNetCore.App&framework_version=6.0.0&arch=x64&rid=centos.7-x64
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。