Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
837 views
in Technique[技术] by (71.8m points)

asp.net mvc - Nuget Update-Package incorrectly updating assembly binding redirects

I have an internal NuGet package that contains a single dll, no external NuGet package dependencies, and no web.config transforms.

Yet when i run Update-Package on my projects (class lib and website) for this specific NuGet, it automatically is updating my website web.config assembly binding redirects to older versions of System.Web.Mvc and Newtonsoft.Json. The website web.config currently has them bound to the latest version being used.

Using the GUI, utilizing Manage NuGet packages for Solution... I choose to UPDATE this NuGet for applicable projects that have a reference to the old version. Then choose Update

Here is the output from Package Manager: http://pastebin.com/3ySwTRFR

And my web.config went from:

  <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>

To:

  <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>

The NuGet package I am updating has a dll which references Newtonsoft.Json (but is not explicitly made a NuGet package dependency)

When unknowing developer updates this NuGet package it breaks the runtime looking for old version of MVC or JSON.NET dlls.

In the past I have attempted to use the -IgnoreDependencies powershell command switch, but this appears to have no impact on the issue.

Any idea on what could be transforming my web.configs (without an explicit transform) during update-package?

Edit: VS2015 w/ NuGet 3.3.0 seems to be behaving better... during random package update it found an old BAD binding redirect and corrected it! enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Skip applying binding redirects is an option now in NuGet 3.3.0: Issue #1147

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...