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

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

问题描述

我使用的是 Visual Studio 2017.我刚刚创建了一个新的 ASP.NET Core 2.0 项目.我试图使用 NuGet 来获取最新的 StackExchange.Redis 1.2.6(截至 2017 年 9 月 3 日).

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

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

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

错误 CS0433 类型 'RedisResult' 存在于 'StackExchange.Redis.StrongName, Version=1.2.4.0, Culture=neutral, PublicKeyToken=c219ff1ca8c2ce46' 和 'StackExchange.Redis, Version=1.2.6.0, Culture=neutral,PublicKeyToken=null' 服务器 C:gitSplashServerBackPlaneConnectionChannel.cs 19 活动

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:gitSplashServerBackPlaneConnectionChannel.cs 19 Active

然后,我发现我真的不需要手动添加任何 NuGet 包来在我的 ASP.NET Core 2.0 应用程序中使用 StackExchange.Redis.事实上,如果我手动添加对不同版本 StackExchange.Redis 的引用,则会导致我上面显示的解决冲突.

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.

检查构建输出.DLL 实际上来自 C:Program FilesdotnetsdkNuGetFallbackFolderstackexchange.redis.strongname

Checked the build output. The DLL is actually coming from C:Program FilesdotnetsdkNuGetFallbackFolderstackexchange.redis.strongname

我尝试删除 stackexchange.redis.strongname 但它仍然以某种方式自动将其下载到我的个人 nuget 文件夹中.

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

感觉就像 ASP.NET Core 2.0 内部需要 StackExchange.Redis 1.2.4.0 但这对我来说真的没有意义.

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.

我在使用 ASP.NET Core 1.1 时没有同样的问题.有什么办法可以让我的 ASP.NET Core 2.0 使用 NuGet 的最新 StackExchange.Redis?

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?

推荐答案

找到原因.这是因为 VS.NET 2017 默认开启了允许 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.

正在恢复 NuGet 包...要防止 NuGet 在构建过程中恢复包,请打开 Visual Studio 选项对话框,单击包管理器节点并取消选中允许 NuGet 在构建过程中下载丢失的包".

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. 转到 Visual Studio 选项对话框.
  2. 取消选中允许 NuGet 下载丢失的包"以避免以后自动下载 NuGet 包
  3. 打开 NuGet 管理器以添加最新的 StackExchange.Redis 包
  4. 单击清除所有 NuGet 缓存"以清除旧的 NuGet 缓存

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

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