asp.net-mvc - Nuget Update-Package 错误地更新程序集绑定(bind)重定向

标签 asp.net-mvc visual-studio-2013 json.net nuget assembly-binding-redirect

我有一个包含单个 dll 的内部 NuGet 包,没有外部 NuGet 包依赖项,也没有 web.config 转换。

然而,当我为这个特定的 NuGet 在我的项目(类库和网站)上运行 Update-Package 时,它​​会自动更新我的网站 web.config 程序集绑定(bind)重定向到 较早的 System.Web.Mvc 和 Newtonsoft.Json 的版本。网站 web.config 当前将它们绑定(bind)到正在使用的最新版本。

使用 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 绑定(bind)重定向并更正了它! enter image description here

最佳答案

在包管理器控制台中使用以下命令

PM> Get-Project –All | Add-BindingRedirect



引用 https://weblog.west-wind.com/posts/2014/nov/29/updating-assembly-redirects-with-nuget详细解释。

关于asp.net-mvc - Nuget Update-Package 错误地更新程序集绑定(bind)重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30358370/

相关文章:

asp.net-mvc - Azure Web 角色 - 混合 MVC 和 WCF - 最佳实践

c# - C# 引用的问题

c# - 序列化列表时显示 JSON 中的索引值

visual-studio-2013 - COBOL 非法文件名

visual-studio - 解决方案中损坏的引用

c# - 无法加载文件或程序集 'Newtonsoft.Json,版本 = 7.0.0.0

c# - Newtonsoft.Json 错误的 JSON 转义序列 :\v.

c# - 与 MVC6/ASP.Net 5 的动态捆绑

javascript - 使用 JavaScript 或 MVC Razor 返回页面

visual-studio - 如何在Visual Studio中使用Bower(从nuget安装)?