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

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

问题描述

我正在运行Visual Studio 2015 Update3。我试图将Redis Cache用于.Net核心应用程序。从此以后,开发的软件包针对.Net标准库。我从github下载了代码,试图改变我的依赖。



这是项目:





首先,我试图将Abstractions类库定位为目标。 Net Core ,然后我尝试添加 Microsoft.Extensions.Primitives ,因为版本1不支持.NET Core。我添加了最后一个预包:

  Install-Package Microsoft.Extensions.Primitives-版本1.0.0-rc1-final -Pre 

无法解决,说


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


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





为什么所有软件包都支持.NET标准库而不支持.NET Core?

解决方案

不知道您到底在做什么,但是由于ASP.NET Core RTM已经使用了几个月,rc1引用似乎是错误的。



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



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



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

  {
version: 1.0.0,
description:使用Redis的Microsoft.Extensions.Caching.Distributed.IDistributedCache的分布式缓存实现。,
packOptions:{
存储库:{
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 (不是强名称)(签名)。不知道这样创建/编译的程序包是否将与其他程序包使用相同的密钥签名,这可能在以后产生问题。如果您使用未签名的程序,则如果您的应用程序本身是强命名的(或者您对所有程序集都具有强签名的业务要求),它也可能会引起问题。



这可以编译并且单元测试通过,没有进一步测试。



其余的问题:



。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标准库的更多信息。 / p>

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.

Here are the projects:

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

It cannot resolve, saying that

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

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?

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

解决方案

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

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).

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

This is my project.json (of 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"
        }
      }
    }
  }
}

No changes required in Microsoft.Extensions.Caching.Abstractions.

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.

As for the rest of your question:

".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天全站免登陆