Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 514
felickz Avatar asked May 20 '15 19:05

felickz


People also ask

Why does Nuget add binding redirects?

Binding redirects are added if your app or its components reference more than one version of the same assembly, even if you manually specify binding redirects in the configuration file for your app. The automatic binding redirection feature affects desktop apps that target .

How do I update my Nuget package?

In Visual Studio, the Package Manager Console provides many flexible options for updating and reinstalling packages. On the Installed tab, select a package, record its name, then select Uninstall. Switch to the Browse tab, search for the package name, select it, then select Install).


Video Answer


1 Answers

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

enter image description here

like image 124
felickz Avatar answered Sep 21 '22 06:09

felickz