当前位置:   article > 正文

Centos7中部署Net6.0程序_centos 安装aspnetcore-runtime-6.0

centos 安装aspnetcore-runtime-6.0

一、第一种方法

添加仓储指令

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)icon-default.png?t=M4ADhttps://dotnet.microsoft.com/en-us/download/dotnet/6.0

wget 

  1. sudo mkdir dotnet
  2. sudo tar zxvf dotnet-sdk-6.0.101-linux-x64.tar.gz -C dotnet

修改环境变量

vi /etc/profile

在文件尾部添加

  1. export PATH=$PATH:/data/dotnet
  2. export DOTNET_ROOT=/data/dotnet

测试dotnet --info

三、程序需改

判断运行环境是不是windows

  1. bool isWindows = System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
  2. string filePath = string.Empty;
  3. if (isWindows)
  4. {
  5. filePath = "c:/" + name;
  6. }
  7. else
  8. {
  9. filePath = "/" + name;
  10. }

四、运行程序

dotnet 程序名.dll

出现以下信息,是因为没有装aspnetcore的运行时,运行yum install aspnetcore-runtime-6.0即可

  1. It was not possible to find any compatible framework version
  2. The framework 'Microsoft.AspNetCore.App', version '6.0.0' (x64) was not found.
  3. - No frameworks were found.
  4. You can resolve the problem by installing the specified framework and/or SDK.
  5. The specified framework can be found at:
  6. - https://aka.ms/dotnet-core-applaunch?framework=Microsoft.AspNetCore.App&framework_version=6.0.0&arch=x64&rid=centos.7-x64
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/897136
推荐阅读
相关标签
  

闽ICP备14008679号