“未定义或导入预定义类型System.ValueTuple”升级到.NET 4.7后 [英] "Predefined type System.ValueTuple is not defined or imported" after upgrading to .NET 4.7

查看:977
本文介绍了“未定义或导入预定义类型System.ValueTuple”升级到.NET 4.7后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要将现有的解决方案从.NET 4.6.2升级到.NET 4.7。此解决方案取决于几个面向.NET 4.6.2的nuget程序包,因此取决于nuget 系统。 Valuetuple 包。

I'm upgrading an existing solution from .NET 4.6.2 to .NET 4.7. This solution depends on several nuget packages that target .NET 4.6.2 and hence depend on the nuget System.ValueTuple package.

但是升级后,我发现了很多这样的构建错误:

But after upgrading, I'm getting a whole bunch of these build errors:

错误CS8179未定义预定义类型'System.ValueTuple`2'或已导入

我无法删除 System.ValueTuple 软件包,如注释 ,因为其他软件包都依赖它。 (如果我强迫这样做,它们似乎会崩溃。)

I can't remove the System.ValueTuple package, as suggested in the comments here, because other packages depend on it. (And if I force it, they seem to blow up.)

有什么建议吗?

更新8/8/17

我发现我可以删除系统。 ValueTuple 包,我可以用这种方式获得解决方案。但是,我在解决方案中有十二个NuGet软件包,它们似乎都针对.NET 4.6.2,因此需要 System.ValueTuple 作为依赖项。我可以安装它们,然后强制删除 System.ValueTuple 程序包,但是如果其中任何一个程序包都有更新,则我将安装更新-然后 System.ValueTuple 程序包再次安装,并且系统停止构建,直到我再次完全删除该程序包为止。

I've figured out that I can remove the System.ValueTuple package, and I can get the solution to compile that way. However, I've got a dozen NuGet packages in the solution which appear to be targeting .NET 4.6.2, and hence require System.ValueTuple as a dependency. I can install those, and then force remove the System.ValueTuple package, but if any of those packages have an update, and I install the update - then the System.ValueTuple package gets installed again, and the system stops building until I remove the package all over again.

我可以使所有工作正常进行-但看起来笨拙而笨拙。当然,有更好的方法可以解决这个问题?

In other words, I can make it all work - but it seems awkward and kludgy. Surely there's a better way to approach this?

推荐答案

是的,升级到 System.ValueTuple 4.4.0

原因如下:


NuGet包 System.ValueTuple 提供了 ValueTuple C#元组语法所需的类型。在.NET Framework 4.7中,我们将类型直接添加到了 mscorlib 中。如果同时使用NuGet包和.NET Framework 4.7,则最终会多次看到相同的类型。这样会导致在Stack Overflow上报告这样的问题。

The NuGet package System.ValueTuple provides the ValueTuple types which are required for the C# tuple syntax. In .NET Framework 4.7 we've added the types directly to mscorlib. If you use both, the NuGet package, as well as .NET Framework 4.7 you'll end up seeing the same types multiple times. This results in issues like this one reported on Stack Overflow.

我们已经更新了NuGet包,以将.NET Framework 4.7上的元组类型键入到<$ c $。 c> mscorlib 。这样可以统一类型,从而允许您使用其他依赖于 System.ValueTuple 的库和NuGet包,同时仍以.NET Framework 4.7为目标。

We've updated the NuGet package to type forward the tuple types on .NET Framework 4.7 to mscorlib. This unifies the types and thus allows you to consume other libraries and NuGet packages that depend on System.ValueTuple while still targeting .NET Framework 4.7.

请参见发行说明

这篇关于“未定义或导入预定义类型System.ValueTuple”升级到.NET 4.7后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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