解决NuGet版本冲突 [英] Resolve NuGet Version Conflict

查看:213
本文介绍了解决NuGet版本冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过NuGet安装更新:

I'm trying to install an update through NuGet:

Microsoft.AspNetCore.Mvc 1.1.2 --> 2.0.4

但是,更新永远不会成功,因为在遇到以下冲突后会回滚:

However, the update never succeeds as it is rolled back after encountering the following conflict:

Version conflict detected for Microsoft.CodeAnalysis.CSharp. Reference the package directly from the project to resolve this issue.


Web -> Microsoft.AspNetCore.Mvc 2.0.4 -> Microsoft.AspNetCore.Mvc.RazorPages 2.0.4 -> 
Microsoft.AspNetCore.Mvc.Razor 2.0.4 -> Microsoft.CodeAnalysis.CSharp (>= 2.3.1) 

Web -> Microsoft.VisualStudio.Web.CodeGeneration.Design 1.1.0 -> 
Microsoft.VisualStudio.Web.CodeGeneration.Utils 1.1.0 ->
 Microsoft.CodeAnalysis.CSharp.Workspaces 1.3.0 -> 
Microsoft.CodeAnalysis.CSharp (= 1.3.0).

因此,据我了解, Microsoft.CodeAnalysis.CSharp 是元凶,因为 Microsoft.AspNetCore.Mvc 具有依赖项,要求它至少为 v2.3.1 ,而 Microsoft.VisualStudio.Web.CodeGeneration.Design 也具有依赖项,要求它为 v1.3.0

So from what I understand from this, Microsoft.CodeAnalysis.CSharp is the culprit since Microsoft.AspNetCore.Mvc has dependencies that require it to be at least v2.3.1 while Microsoft.VisualStudio.Web.CodeGeneration.Design also has dependencies which requires it to be v1.3.0

我不确定该如何解决.它确实说直接从项目中引用该软件包以解决此问题,但我真的不明白这意味着什么以及如何实现.

I'm not sure how to solve this. It does say Reference the package directly from the project to resolve this issue but I don't really understand what this means and how to do it.

推荐答案

如果直接添加依赖项包(在这种情况下,将NuGet包 Microsoft.CodeAnalysis.CSharp 添加到您的项目中)Visual Studio将使用直接引用的软件包的版本,而不是其他软件包的依赖项中指定的版本.这样,您已经指定了如何通过安装特定版本的依赖项来解决冲突.

If you add the dependency package directly (add the NuGet package Microsoft.CodeAnalysis.CSharp to your project in this case) Visual Studio will use the version of the directly referenced package rather than the versions specified in the dependencies of your other packages. In this way you have specified how to resolve the conflict by installing a specific version of the dependency.

您可以像其他任何NuGet软件包一样添加此引用:在VisualStudio中,右键单击项目->管理NuGet软件包...",搜索 Microsoft.CodeAnalysis.CSharp 并安装它.

You add this reference as you would any other NuGet package: in VisualStudio right-click on project -> "Manage NuGet Packages..." search for Microsoft.CodeAnalysis.CSharp and install it.

这篇关于解决NuGet版本冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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