【问题标题】:JWT nuget package cannot be restoredJWT nuget包无法恢复
【发布时间】:2018-06-26 16:05:24
【问题描述】:

我在 CentOS 上安装了 dotnet core,还有一个正在使用 JWT 的项目

https://www.nuget.org/packages/JWT/3.1.1

在我的 OSX 上本地恢复非常好:

dotnet --info
.NET Command Line Tools (2.0.3)

Product Information:
Version:            2.0.3
Commit SHA-1 hash:  eb1d5ee318

Runtime Environment:
OS Name:     Mac OS X
OS Version:  10.13
OS Platform: Darwin
RID:         osx.10.12-x64
Base Path:   /usr/local/share/dotnet/sdk/2.0.3/

Microsoft .NET Core Shared Framework Host

Version  : 2.0.3
Build    : a9190d4a75f4a982ae4b4fa8d1a24526566c69df

服务器:

dotnet --info
.NET Command Line Tools (2.0.3)

Product Information:
Version:            2.0.3
Commit SHA-1 hash:  c85173f757

Runtime Environment:
OS Name:     centos
OS Version:  7
OS Platform: Linux
RID:         centos.7-x64
Base Path:   /opt/rh/rh-dotnet20/root/usr/lib64/dotnet/sdk/2.0.3/

Microsoft .NET Core Shared Framework Host

Version  : 2.0.3
Build    : N/A

但在服务器上它不起作用:

dotnet add package JWT --version 3.1.1
Writing /tmp/tmphdc0Ux.tmp
error: Unable to load the service index for source 
https://api.nuget.org/v3/index.json.
error:   The type initializer for 'System.Net.Http.CurlHandler' threw an exception.
error:   The type initializer for 'Http' threw an exception.
error:   The type initializer for 'HttpInitializer' threw an exception.
error:   Unable to load DLL 'System.Net.Http.Native': The specified module or one of its dependencies could not be found.
error:    (Exception from HRESULT: 0x8007007E)

dotnet 安装命令:

yum install centos-release-dotnet
yum install rh-dotnet20 

我尝试了 dotnet clean,并尝试将软件包版本更改为新版本或旧版本,但没有任何效果。我的 .csproj 中的其他软件包已成功恢复,任何建议将不胜感激。

【问题讨论】:

  • 我创建了一张 CentOS7 的镜像,没有任何问题 sample output。您收到的错误似乎是由于 dotnet SDK 的安装不完整和/或损坏。你是怎么安装的?如果您是从 Microsoft 产品源安装的,那么您会从 yum list installed | grep microsoft 获得什么输出?
  • @Pace,感谢您的评论,我编辑了问题以说明我是如何安装 dotnet 的。 yum list installed | grep microsoft 不返回任何内容

标签: .net asp.net-core nuget


【解决方案1】:

当 .NET Core 的某些本机先决条件未得到满足时,会发生此错误。在这种情况下,libcurl 要么不存在,要么安装了不兼容的版本

请查阅Prerequisites for .NET Core on Linux 文档并确保您使用的是最新版本(当前是 .NET Core Sdk 2.1.4,而您一直在使用 2.0.3)

【讨论】:

  • 其他包正在安装中,我的csproj中的所有包都可以,除了这个
  • 许多包(例如 System.YYY)内置在 dotnet 运行时中,因此实际上不需要从 Internet 安装。这可能是第一个远程包吗?
  • 我刚刚又检查了一遍,所有先决条件,这是唯一没有安装的:lttng-ust 安装了它,但无济于事。这是一个用于 mysql 的软件包 Pomelo.EntityFrameworkCore.MySql 并安装,另一个用于 swagger Swashbuckle.AspNetCore 也正确安装
  • @Pace & Martin,其实是Pace提出的,我安装dotnet的方式不好,按照Martin的url上的说明,现在可以正常使用了。
猜你喜欢
  • 1970-01-01
  • 2018-05-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-05-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多