Asp.net-Mvc

Nuget Update-Package 錯誤地更新程序集綁定重定向

  • May 20, 2015

我有一個包含單個 dll 的內部 NuGet 包,沒有外部 NuGet 包依賴項,也沒有 web.config 轉換。

然而,當我為這個特定的 NuGet 在我的項目(類庫和網站)上執行 Update-Package 時,它會自動更新我的網站 web.config 程序集綁定重定向到版本的 System.Web.Mvc 和 Newtonsoft.Json。網站 web.config 目前將它們綁定到正在使用的最新版本。

使用 GUI,利用管理 NuGet 包進行解決方案…我選擇為引用舊版本的適用項目更新此 NuGet。然後選擇更新

這是包管理器的輸出:http: //pastebin.com/3ySwTRFR

我的 web.config 來自:

 <dependentAssembly>
   <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
   <bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
 </dependentAssembly>

 <dependentAssembly>
   <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
   <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
 </dependentAssembly>

到:

 <dependentAssembly>
   <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
   <bindingRedirect oldVersion="0.0.0.0-4.0.0.1" newVersion="4.0.0.1" />
 </dependentAssembly>

 <dependentAssembly>
   <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
   <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
 </dependentAssembly>

我正在更新的 NuGet 包有一個引用 Newtonsoft.Json 的 dll(但沒有明確地成為 NuGet 包依賴項)

當不知情的開發人員更新此 NuGet 包時,它會破壞執行時尋找舊版本的 MVC 或 JSON.NET dll。

過去我曾嘗試使用-IgnoreDependencies powershell command switch,但這似乎對問題沒有影響。

關於在更新包期間可以轉換我的 web.configs(沒有顯式轉換)的任何想法?

編輯:帶有 NuGet 3.3.0 的 VS2015 似乎表現得更好……在隨機包更新期間,它發現了一個舊的 BAD 綁定重定向並更正了它!在此處輸入圖像描述

跳過應用綁定重定向現在是 NuGet 3.3.0 中的一個選項:問題 #1147

在此處輸入圖像描述

引用自:https://stackoverflow.com/questions/30358370