linux,发布.netcore填坑,自动升级core版本后,运行报错:'Microsoft.AspNetCore.App', version '3.0.0' was not found.

时间:2021-05-06 14:35:20

近来有点空,所以研究下,netcore这个神器~   

号称跨平台的利器,从此net不在局限于windows服务器了,早点该多好呀,这样我们net程序员,不香吗?

网上搜,‘netcore 发布liunx’文章很多,照着弄就是了,只是用云安装的模式,会有个大坑!下面细说

vs2019  netcore3.0 编译的web工程,调试一切正常,发布成可移植的类型

一步步搭建liunx的netcore环境,安装core3.0,一切都正常

利用ftp上传编译的工程文件到liunx,启用命令‘dotnet ***.dll’ ,提示异常:(具体如下)

$ dotnet WebApplication2.dll
It was not possible to find any compatible framework version
The specified framework 'Microsoft.AspNetCore.App', version '3.0.0' was not found.
- The following frameworks were found:
2.1.14 at [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]

You can resolve the problem by installing the specified framework and/or SDK.

The .NET Core frameworks can be found at:
- https://aka.ms/dotnet-download

分析:我是3.0的环境,但是其中的 Microsoft.AspNetCore.App 这个库才2.1.14!!!导致版本不统一,环境缺失!

验证:netcore环境在目录 /usr/share/dotnet/shared/Microsoft.AspNetCore.App/ 里

结论:的确,里面只有2.1.14文件夹,缺少我需要的3.0.0环境

解决:通过分析终端输出的提示,访问 ‘https://aka.ms/dotnet-download’ 到官网下载程序包,解压并找到对应文件夹,下面通过图文介绍

linux,发布.netcore填坑,自动升级core版本后,运行报错:'Microsoft.AspNetCore.App', version '3.0.0' was not found.

linux,发布.netcore填坑,自动升级core版本后,运行报错:'Microsoft.AspNetCore.App', version '3.0.0' was not found.

linux,发布.netcore填坑,自动升级core版本后,运行报错:'Microsoft.AspNetCore.App', version '3.0.0' was not found.

linux,发布.netcore填坑,自动升级core版本后,运行报错:'Microsoft.AspNetCore.App', version '3.0.0' was not found.

linux,发布.netcore填坑,自动升级core版本后,运行报错:'Microsoft.AspNetCore.App', version '3.0.0' was not found.

linux,发布.netcore填坑,自动升级core版本后,运行报错:'Microsoft.AspNetCore.App', version '3.0.0' was not found.

把这个文件夹整体通过ftp传到liunx去,liunx的路径是‘/usr/share/dotnet/shared/Microsoft.AspNetCore.App/’

需要注意的是,只能用root用户才可以管理这个目录的,所以你的ftp登录的时候,直接用root即可,下面的摘要,仅供参考

linux,发布.netcore填坑,自动升级core版本后,运行报错:'Microsoft.AspNetCore.App', version '3.0.0' was not found.

linux,发布.netcore填坑,自动升级core版本后,运行报错:'Microsoft.AspNetCore.App', version '3.0.0' was not found.

验证:回到liunx系统,利用‘dotnet’命令启用即可,下面是摘要

linux,发布.netcore填坑,自动升级core版本后,运行报错:'Microsoft.AspNetCore.App', version '3.0.0' was not found.

搞定!!!!