VS.NET 2017强制在ASP.NET 2.0 Core应用中使用StackExchange.Redis 1.2.4.0 [英] VS.NET 2017 forces using StackExchange.Redis 1.2.4.0 in ASP.NET 2.0 Core app

查看:197
本文介绍了VS.NET 2017强制在ASP.NET 2.0 Core应用中使用StackExchange.Redis 1.2.4.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Visual Studio2017。我刚刚创建了一个新的ASP.NET Core 2.0项目。我试图使用NuGet引入最新的StackExchange.Redis 1.2.6(截至2017年9月3日)。



但是,一旦我这样做,Visual Studio抱怨我的RedisResult变量之一中的引用存在冲突。它说


错误CS0433类型'RedisResult'存在于两个'StackExchange.Redis.StrongName,版本= 1.2.4.0,Culture = neutral中,PublicKeyToken = c219ff1ca8c2ce46和 StackExchange.Redis,版本= 1.2.6.0,Culture = neutral,PublicKeyToken = null服务器C:\git\Splash\Server\BackPlaneConnection\Channel.cs 19有效


然后,我发现我真的不需要手动添加任何NuGet包即可在ASP.NET中使用StackExchange.Redis核心2.0应用。实际上,如果我手动添加对另一个版本的StackExchange.Redis的引用,则会导致我在上面显示的解决冲突。



检查了构建输出。该DLL实际上来自C:\Program Files\dotnet\sdk\NuGetFallbackFolder\stackexchange.redis.strongname



我尝试删除stackexchange.redis。

这几乎感觉像ASP.NET Core 2.0内部需要StackExchange.Redis 1.2.4.0,但这确实没有



使用ASP.NET Core 1.1时,我没有相同的问题。有什么办法让我的ASP.NET Core 2.0使用来自NuGet的最新StackExchange.Redis?

解决方案

找到了原因。这是因为默认情况下,VS.NET 2017启用了允许NuGet下载丢失的程序包。


还原NuGet软件包...
要防止NuGet在构建过程中还原软件包,请打开。在 Visual Studio选项对话框中,单击程序包管理器节点,然后取消选中允许NuGet在生成过程中下载丢失的程序包。


,要完全避免此问题,我需要执行以下步骤来解决我的问题。


  1. 转到 Visual Studio选项对话框。

    li>
  2. 取消选中允许NuGet下载丢失的软件包,以避免将来以后自动下载NuGet软件包

  3. 打开NuGet Manager以添加最新的StackExchange.Redis软件包

  4. 单击清除所有NuGet缓存以清理旧的NuGet缓存


I am using Visual Studio 2017. I just created a new ASP.NET Core 2.0 project. I was trying to use NuGet to pull in the latest StackExchange.Redis 1.2.6 (as of 9/3/2017).

However, once I do that, Visual Studio complains that there is a conflicted reference in one of my RedisResult variable. It said

Error CS0433 The type 'RedisResult' exists in both 'StackExchange.Redis.StrongName, Version=1.2.4.0, Culture=neutral, PublicKeyToken=c219ff1ca8c2ce46' and 'StackExchange.Redis, Version=1.2.6.0, Culture=neutral, PublicKeyToken=null' Server C:\git\Splash\Server\BackPlaneConnection\Channel.cs 19 Active

Then, I found out that I don't really need to manually add any NuGet package in order to use StackExchange.Redis in my ASP.NET Core 2.0 app. In fact, if I manually add a reference to a different version of StackExchange.Redis, it causes the resolve conflict that I showed above.

Checked the build output. The DLL is actually coming from C:\Program Files\dotnet\sdk\NuGetFallbackFolder\stackexchange.redis.strongname

I tried deleting stackexchange.redis.strongname but it somehow still download it to my personal nuget folder automatically.

It almost feels like ASP.NET Core 2.0 internally needs StackExchange.Redis 1.2.4.0 but this really doesn't make sense to me.

I don't have the same problem when using ASP.NET Core 1.1. Is there any way to let my ASP.NET Core 2.0 use the latest StackExchange.Redis from NuGet?

解决方案

Found the reason. It's because by default VS.NET 2017 turned on the "Allow NuGet to download missing packages". The build screen also mentioned that.

Restoring NuGet packages... To prevent NuGet from restoring packages during build, open the Visual Studio Options dialog, click on the Package Manager node and uncheck 'Allow NuGet to download missing packages during build.'

In my case, to completely avoid this problem, I need to do the following steps to resolve my problem.

  1. Go to Visual Studio Options dialog.
  2. Uncheck "Allow NuGet to download missing packages" to avoid downloading the NuGet package automatically in the future
  3. Open NuGet Manager to add the latest StackExchange.Redis package
  4. Click "Clear All NuGet Cache(s)" to clean up the old NuGet cache

这篇关于VS.NET 2017强制在ASP.NET 2.0 Core应用中使用StackExchange.Redis 1.2.4.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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