发现无法解决的相同从属程序集的不同版本之间的冲突

本文翻译自:Found conflicts between different versions of the same dependent assembly that could not be resolved

When I clean and then build my solution that has several projects, the output window reports that the build succeeded. 当我清理并构建具有多个项目的解决方案时,输出窗口将报告构建成功。 However, when I view the Error List Window , it shows me this warning: 但是,当我查看“ 错误列表窗口”时 ,它显示以下警告:

Found conflicts between different versions of the same dependent assembly that could not be resolved. 发现无法解决的相同从属程序集的不同版本之间的冲突。 These reference conflicts are listed in the build log when log verbosity is set to detailed. 将日志详细程度设置为“详细”时,这些参考冲突会在构建日志中列出。 C:\\Program Files (x86)\\MSBuild\\12.0\\bin\\Microsoft.Common.CurrentVersion.targets C:\\ Program Files(x86)\\ MSBuild \\ 12.0 \\ bin \\ Microsoft.Common.CurrentVersion.targets

When I double-click this message, it opens the C:\\Program Files (x86)\\MSBuild\\12.0\\bin\\Microsoft.Common.CurrentVersion.targets file but I don't understand anything in it. 当我双击此消息时,它将打开C:\\ Program Files(x86)\\ MSBuild \\ 12.0 \\ bin \\ Microsoft.Common.CurrentVersion.targets文件,但其中的任何内容我都不理解。

I am using Visual Studio Express 2013 for the Web. 我正在将Visual Studio Express 2013用于Web。

How do I find out what's wrong and with which DLL and how do I then make the warning go away? 如何找出问题所在以及哪个DLL,然后如何使警告消失?


#1楼

参考:https://stackoom.com/question/1fwLF/发现无法解决的相同从属程序集的不同版本之间的冲突


#2楼

Run msbuild Foo.sln /t:Rebuild /v:diag (from C:\\Program Files (x86)\\MSBuild\\12.0\\bin ) to build your solution from command line and get a bit more details, then find the .csproj. 运行msbuild Foo.sln /t:Rebuild /v:diag (来自C:\\Program Files (x86)\\MSBuild\\12.0\\bin ),从命令行构建解决方案并获得更多详细信息,然后找到.csproj. that logs the warning and check its references and references of other projects that use the same common assembly that differs in version. 该日志记录警告并检查其引用以及使用版本不同的相同通用程序集的其他项目的引用。

Edit: You can also set the build verbosity directly in VS2013. 编辑:您也可以直接在VS2013中设置构建详细程度。 Go to Tools > Options menu then go to Projects and Solutions and set MSBuild verbosity to Diagnostic . 转到“ Tools >“ Options菜单,然后转到“ Projects and Solutions ,并将MSBuild详细程度设置为“ Diagnostic

Edit: Few clarifications as I just got one myself. 编辑:很少澄清,因为我自己一个人。 In my case warning was due to me adding a reference using Resharper prompt as opposed to the Add Reference dialog, which did it versionless even though both v4 and v12 are available to choose from. 在我的情况下,警告是由于我使用Resharper提示符而不是“添加引用”对话框添加了引用,即使v4和v12都可以选择,该对话框也没有版本。

<Reference Include="Microsoft.Build, Version=12.0.0.0, ..." />
<Reference Include="Microsoft.Build.Framework" />

vs

<Reference Include="Microsoft.Build, Version=12.0.0.0, ..." />
<Reference Include="Microsoft.Build.Framework, Version=12.0.0.0, ..." />

In the MSBuild log with /v:diag verbosity it looked like the following. 在具有/v:diag详细信息的MSBuild日志中,它看起来如下所示。 giving details which two references conflicted:- 提供两个参考有冲突的细节:

  There was a conflict between 
  "Microsoft.Build.Framework, Version=4.0.0.0, ..." and 
  "Microsoft.Build.Framework, Version=12.0.0.0, ...". (TaskId:16)

      "Microsoft.Build.Framework, Version=4.0.0.0, ..." was chosen because it was primary and 
      "Microsoft.Build.Framework, Version=12.0.0.0, ..." was not. (TaskId:16)

      References which depend on "Microsoft.Build.Framework, Version=4.0.0.0, ..." 
      [C:\...\v4.5.1\Microsoft.Build.Framework.dll]. (TaskId:16)

          C:\...\v4.5.1\Microsoft.Build.Framework.dll (TaskId:16)
            Project file item includes which caused reference "C:\...\v4.5.1\Microsoft.Build.Framework.dll". (TaskId:16)
              Microsoft.Build.Framework (TaskId:16)

      References which depend on "Microsoft.Build.Framework, Version=12.0.0.0, ..." 
      [C:\...\v12.0\Microsoft.Build.Framework.dll]. (TaskId:16)

          C:\...\v12.0\Microsoft.Build.dll (TaskId:16)
            Project file item includes which caused reference "C:\...\v12.0\Microsoft.Build.dll". (TaskId:16)
              Microsoft.Build, Version=12.0.0.0, ... (TaskId:16)

          C:\...\v12.0\Microsoft.Build.Engine.dll (TaskId:16)
            Project file item includes which caused reference "C:\...\v12.0\Microsoft.Build.Engine.dll". (TaskId:16)
              Microsoft.Build, Version=12.0.0.0, ... (TaskId:16)

C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(1697,5): warning MSB3277: 
Found conflicts between different versions of the same dependent assembly that could not be resolved.  
These reference conflicts are listed in the build log when log verbosity is set to detailed. 
[C:\Users\Ilya.Kozhevnikov\Dropbox\BuildTree\BuildTree\BuildTree.csproj]

#3楼

and how do I then make the warning go away? 然后如何使警告消失?

You are probably going to have to reinstall or upgrade your NuGet packages to fix this. 您可能需要重新安装或升级NuGet软件包才能解决此问题。


#4楼

While the other responses say this, they don't make it explicit, so I will.... 尽管其他回应都这样说,但他们并未明确指出,所以我会...

On VS2013.2, to actually trigger the emission of the cited information, you need to not read the message, which says: 在VS2013.2上,要实际触发所引用信息的发布,您无需阅读该消息,该消息显示:

C:\\Program Files (x86)\\MSBuild\\12.0\\bin\\Microsoft.Common.CurrentVersion.targets(1697,5): warning MSB3277: Found conflicts between different versions of the same dependent assembly that could not be resolved. C:\\ Program Files(x86)\\ MSBuild \\ 12.0 \\ bin \\ Microsoft.Common.CurrentVersion.targets(1697,5):警告MSB3277:在相同的依赖程序集的不同版本之间发现了无法解决的冲突。 These reference conflicts are listed in the build log when log verbosity is set to detailed . 将日志详细程度设置为 detail时,这些参考冲突会在构建日志中列出。

This is incorrect (or at least it was for some versions of Visual Studio - it seems to be OK on an up to date VS2015 Update 3 or later). 这是不正确的(或者至少是某些Visual Studio版本的-在最新的VS2015 Update 3或更高版本上似乎可以)。 Instead turn it to Diagnostic (from Tools->Options->Project and Solutions->Build and Run , set MSBuild project build output verbosity ), whereupon you'll see messages such as: 而是将其转到Diagnostic (从“ 工具”->“选项”->“项目和解决方案”->“构建和运行”中 ,设置MSBuild项目的构建输出详细程度 ),随后您将看到以下消息:

There was a conflict between "Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" and "Newtonsoft.Json, Version=6.0.5.17707, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed". “ Newtonsoft.Json,版本= 6.0.0.0,文化=中性,PublicKeyToken = 30ad4fe6b2a6aeed”和“ Newtonsoft.Json,版本= 6.0.5.17707,文化=中性,PublicKeyToken = 30ad4fe6b2a6aeed”之间存在冲突。

  • "Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" was chosen because it was primary and "Newtonsoft.Json, Version=6.0.5.17707, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" was not. 选择“ Newtonsoft.Json,版本= 6.0.0.0,文化=中性,PublicKeyToken = 30ad4fe6b2a6aeed”,因为它是主要的,而未选择“ Newtonsoft.Json,版本= 6.0.5.17707,文化=中性,PublicKeyToken = 30ad4fe6b2a6aeed”。

Then 然后

  • Ctrl-Alt-O to go to Build output window Ctrl-Alt-O转到“构建输出”窗口
  • search for " was chosen " to find the drilldown. 搜索“ 被选择 ”以查找明细。

...And yes, for those looking at the detail of the [diagnostic] message, it was news to this ignoramus that there's a convention in town whereby all 6.x versions are, internally Assembly Version 6.0.0.0 , ie only the SemVer Major component goes into the Assembly Version :) ...是的,对于那些查看[诊断]消息详细信息的人来说,这是一个无聊的消息, 镇上有一个约定,所有6.x版本在内部都是Assembly Version 6.0.0.0 ,即仅SemVer主要组件进入组装版本 :)


#5楼

I have uninstalled Microsoft ASP.NET MVC nuget.org from manage NuGet Packagaes and again re-installed it. 我已经从管理NuGet Packagaes卸载了Microsoft ASP.NET MVC nuget.org,然后再次重新安装了它。 While re-installing it resolved all the conflicts related to razor version. 重新安装时,它解决了与剃须刀版本有关的所有冲突。 Try it . 试试吧 。


#6楼

I can only support further Ruben's answer with a comparison between the two messages displayed: 我只能通过比较显示的两个消息来支持鲁宾的答案:

在此处输入图片说明

and the message: 和消息:

C:\\Program Files (x86)\\MSBuild\\12.0\\bin\\Microsoft.Common.CurrentVersion.targets(1697,5): warning MSB3277: Found conflicts between different versions of the same dependent assembly that could not be resolved. C:\\ Program Files(x86)\\ MSBuild \\ 12.0 \\ bin \\ Microsoft.Common.CurrentVersion.targets(1697,5):警告MSB3277:在相同的依赖程序集的不同版本之间发现了无法解决的冲突。 These reference conflicts are listed in the build log when log verbosity is set to detailed . 这些参考冲突在构建日志中列出当日志级别设置为详细

So, Ruben's right—this is just not true. 因此,鲁宾是对的-这不是事实。 There are no conflicts whatsoever, just a missing assembly. 没有任何冲突,只是缺少一个程序集。 This is especially boring when the project is an ASP.NET application, since the views are compiled on demand , that is, just before displayed for the first time. 当项目是ASP.NET应用程序时,这尤其无聊,因为视图是按需编译的,也就是在第一次显示之前。 This is when it becomes necessary to have the assembly available. 这是当有必要使该组件可用时。 (There's an option to pre-compile the views together with the rest of the code, but this is another story .) On the other hand, if you set the verbosity to Diagnostic you get the following output: (有一个选项可以将视图与代码的其余部分一起预编译,但这是另一回事了 。)另一方面,如果将详细程度设置为Diagnostic,则会得到以下输出:

C:\\Program Files (x86)\\MSBuild\\12.0\\bin\\Microsoft.Common.CurrentVersion.targets(1697,5): warning MSB3245: Could not resolve this reference. C:\\ Program Files(x86)\\ MSBuild \\ 12.0 \\ bin \\ Microsoft.Common.CurrentVersion.targets(1697,5):警告MSB3245:无法解析此引用。 Could not locate the assembly "System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL". 无法找到程序集“ System.Web.Razor,版本= 3.0.0.0,区域性=中性,PublicKeyToken = 31bf3856ad364e35,processorArchitecture = MSIL”。 Check to make sure the assembly exists on disk. 检查以确保程序集在磁盘上。 If this reference is required by your code, you may get compilation errors. 如果您的代码需要此引用,则可能会出现编译错误。

As a result, all you need to do is either: 结果,您需要做的是:

  1. Add a reference to the assembly manually (locate it on disk, maybe GAC, and add it as a "direct" reference), or 手动添加对程序集的引用(将其定位在磁盘上,也许是GAC上,并将其添加为“直接”引用),或者
  2. Use NuGet package (if published in the gallery) to download it and reference the assembly contained within it. 使用NuGet软件包(如果在图库中发布)下载并引用其中包含的程序集。

More about NuGet gallery here . 有关NuGet画廊的更多信息,请点击此处 More about precompiling ASP.NET views here . 有关在此处预编译ASP.NET视图的更多信息。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值