發現無法解決的相同從屬程序集的不同版本之間的衝突

本文翻譯自: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視圖的更多信息。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章