尝试解决依赖关系:将 .NET 标准库更改为 NET Core - Microsoft.Extensions.Primitives [英] Trying to resolve dependencies: Changing .NET Standard Library to NET Core - Microsoft.Extensions.Primitives

查看:24
本文介绍了尝试解决依赖关系:将 .NET 标准库更改为 NET Core - Microsoft.Extensions.Primitives的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行 Visual Studio 2015 Update 3.我正在尝试将 Redis 缓存用于 .Net 核心应用程序.因为,开发的包是针对 .Net 标准库的.我从 github 下载了代码并尝试更改我自己的依赖项.

I am running Visual Studio 2015 Update 3. I am trying to use Redis Cache for .Net core applications. Since, the developed package is targeting .Net Standard Library. I downloaded the code from github and trying to change the dependecies my self.

这里是项目:

首先,我尝试将抽象类库更改为目标 .Net Core,然后我尝试添加 Microsoft.Extensions.Primitives,从版本 1 开始不支持 .NET Core.我添加了最终的预包:

First, I am trying to chage the Abstractions Class Library to target .Net Core, then i tried to add the Microsoft.Extensions.Primitives, Since the version 1 does not support .NET Core. I added the final pre package:

Install-Package Microsoft.Extensions.Primitives -Version 1.0.0-rc1-final -Pre

无法解决,说

无法解析依赖项 Microsoft.Extensions.Primitives >= 1.0.0-rc1-final.

The dependency Microsoft.Extensions.Primitives >= 1.0.0-rc1-final could not be resolved.

我如何解决这个问题以使其适用于 .NET Core?.NET Core 1 与 .NET Core 5 有何不同,因为它们是我安装的包的依赖项?

How Can I fix that to make it work for .NET Core? How is .NET Core 1 different from .NET Core 5, since these are dependencies of the package I installed?

为什么所有的包都支持 .NET Standard Libary 而不是 .NET Core?

Why all the packages support .NET Standard Libary and not .NET Core?

推荐答案

不知道你在做什么,但是 rc1 引用似乎是错误的,现在 ASP.NET Core RTM 已经发布了几个月.

Dunno what exactly you're doing, but rc1 references seem wrong, now that ASP.NET Core RTM is out for several months.

我抓了 1.0.0 的源代码(你必须专门选择 1.0.0 标签.Master 分支基于 ASP.NET Core 1.1).

I grabbed the 1.0.0 sourced (you have to specifically choose the 1.0.0 tag. Master branch is based on ASP.NET Core 1.1).

我唯一改变的是project.json(除了Microsoft.Extensions.Caching.Redis.Test,我卸载了其他卸载的无关项目和测试项目.

Only thing I changed is project.json (I unloaded the other unloaded unrelated projects and test projects except Microsoft.Extensions.Caching.Redis.Test.

这是我的project.json(Microsoft.Extensions.Caching.Redis):

{
  "version": "1.0.0",
  "description": "Distributed cache implementation of Microsoft.Extensions.Caching.Distributed.IDistributedCache using Redis.",
  "packOptions": {
    "repository": {
      "type": "git",
      "url": "https://github.com/aspnet/caching"
    },
    "tags": [
      "cache",
      "distributedcache",
      "redis"
    ]
  },
  "buildOptions": {
    "warningsAsErrors": true,
    "keyFile": "../../tools/Key.snk",
    "nowarn": [
      "CS1591"
    ],
    "xmlDoc": true
  },
  "dependencies": {
    "Microsoft.Extensions.Caching.Abstractions": "1.0.0",
    "Microsoft.Extensions.Options": "1.0.0",
    "StackExchange.Redis.StrongName": "1.1.608"
  },
  "frameworks": {
    "netstandard1.5": { },
    "net451": {
      "dependencies": { },
      "frameworkAssemblies": {
        "System.Runtime": {
          "type": "build"
        }
      }
    }
  }
}

Microsoft.Extensions.Caching.Abstractions 中无需更改.

或者,您可以使用 StackExchange.Redis 而不是 StackExchange.Redis.StrongName ,后者不是强命名(签名).不确定如此创建/编译的包是否将使用与其他包相同的密钥进行签名,这可能会在以后产生问题.如果您使用未签名的,那么它也可能会产生问题,如果您的应用程序本身是强命名的(或者您有所有程序集都具有强签名的业务要求).

Alternatively you can use StackExchange.Redis instead of StackExchange.Redis.StrongName which isn't strong named (signed). Not sure if the so created/compiled package will be signed with the same key as the other packages, which may create issues later. If you use unsigned one then it also may create issues, if your application is strong named itself (or you have business requirement that all assemblies are strong signed).

这会编译并且单元测试通过,没有进一步测试.

This compiles and the unit tests pass, didn't test further.

至于您的其余问题:

".NET Core 5" nuget 目标是 dnx50,它一直使用到 ASP.NET Core rc1.随着 rc2 ASP.NET Core 切换到 dotnet-cli,DNX 现在不受支持并且不会收到任何进一步的更新.rc2 引入了 netstandard 来简化类库的创建,这些类库可以针对大多数可用平台(完整的 .NET Framework、.NET Core、WinRT/WindowsPhone/Windows8/Windows10、mono、Xamarin 等)).您可以了解有关 .NET 标准库的更多信息.

".NET Core 5" nuget target is dnx50 which was used up until ASP.NET Core rc1. With rc2 ASP.NET Core switched to the dotnet-cli and DNX is unsupported now and won't receive any further updates. With rc2 the netstandard was introduced to simplify creation of class libraries which can target most of the platforms available (full .NET Framework, .NET Core, WinRT/WindowsPhone/Windows8/Windows10, mono, Xamarin, etc). You can learn more about the .NET Standard Library.

这篇关于尝试解决依赖关系:将 .NET 标准库更改为 NET Core - Microsoft.Extensions.Primitives的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆