The specified framework 'Microsoft.NETCore.App', version '1.0.1' was not found 解决办法

章永安
2023-12-01

环境:Centos 7

已经下载安装.NET Core 1.1

Microsoft .NET Core Shared Framework Host

  Version  : 1.1.0
  Build    : 928f77c4bc3f49d892459992fb6e1d5542cb5e86

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

 

问题:

通过VS2015 update3 创建的项目,默认是NetcoreApp,Version1.0。发布release后,拷贝到linux。cd到程序目录,运行“dotnet  myapp.dll",报:

[root@master PublishOutput]# dotnet ConsoleApp1.dll
The specified framework 'Microsoft.NETCore.App', version '1.0.1' was not found.
  - Check application dependencies and target a framework version installed at:
      /opt/dotnet/shared/Microsoft.NETCore.App
  - The following versions are installed:
      1.1.0
  - Alternatively, install the framework version '1.0.1'.

 

分析:

1、centos安装dotnet 过程

sudo yum install libunwind libicu
curl -sSL -o dotnet.tar.gz https://go.microsoft.com/fwlink/?LinkID=835019 
sudo mkdir -p /opt/dotnet && sudo tar zxf dotnet.tar.gz -C /opt/dotnet
sudo ln -s /opt/dotnet/dotnet /usr/local/bin

下载dotnet.tar.gz 后,解压程序包,并使用“ln"命令把解压文件dotnet连接到目录”/usr/local/bin",使得在输入“dotnet"命令时,调用”/opt/dotnet/dotnet"

 

2、查看“/opt/dotnet”目录

[root@master PublishOutput]# cd /opt/dotnet
[root@master dotnet]# ls
dotnet  host  LICENSE.txt  sdk  shared  ThirdPartyNotices.txt

"cd shared" 目录只有Micorsoft.NETCore.App,版本只有1.1.0

[root@master dotnet]# cd shared
[root@master shared]# ls
Microsoft.NETCore.App
[root@master shared]# cd Microsoft.NETCore.App
[root@master Microsoft.NETCore.App]# ls
1.1.0

 

思考:在安装dotnet过程中,也只是解压文件,能否通过在Micorsoft.NETCore.App目录下,添加netcore1.0.1的1.0.1目录文件就可以解决呢

 

行动:
1、http://www.microsoft.com/net/download/linux 下载netcore1.0.1,release版本,解压文件。

2、拷贝Micorsoft.NETCore.App目录下的1.0.1目录文件到“/opt/dotnet/shared/Micorsoft.NETCore.App/"

3、cd到应用程序目录,测试"dotnet myapp.dll",如:

[root@master ~]# cd  PublishOutput
[root@master PublishOutput]# ls
ConsoleApp1.deps.json  ConsoleApp1.pdb
ConsoleApp1.dll        ConsoleApp1.runtimeconfig.json
[root@master PublishOutput]# dotnet ConsoleApp1.dll
hello world

输出了“hello world",问题解决。

 

转载于:https://www.cnblogs.com/hobinly/p/6169165.html

 类似资料: