Can I tell bindingRedirect to always use the latest available version?

Uwe Keim picture Uwe Keim · Jun 30, 2014 · Viewed 8k times · Source

Having an ASP.NET application there are several entries in the Web.Config file in this format:

<dependentAssembly>
    <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="0.0.0.0-1.6.5135" newVersion="1.6.5135" />
</dependentAssembly>

These libraries come as NuGet packages.

Now every time I update my 20+ NuGet packages I do something like:

  1. One click to update all packages.
  2. Open the application in browser.
  3. See errors like this one.
  4. Open my Web.Config, find the binding redirect entry.
  5. Lookup the assemblies latest version.
  6. Modify my web.config.
  7. Update those steps 2…6 for all other updated NuGet packages with binding redirects.

This is very annoying.

My question:

Is there a way to tell the bindingRedirect entry to always use the latest version?

E.g. something like:

<bindingRedirect oldVersion="0.0.0.0-*" newVersion="*" />

(Using a wildcard to tell the latest version)

The closest I came accross is something like:

<bindingRedirect oldVersion="0.0.0.0-9.9.9.9" newVersion="1.6.5135" />

(Only specify the newest version once)

Answer

Bringer128 picture Bringer128 · Jul 16, 2015

Unfortunately, the answer to this is no. See the bindingRedirect element on MSDN.

To quote:

oldVersion: Required attribute.

Specifies the version of the assembly that was originally requested. The format of an assembly version number is major.minor.build.revision. Valid values for each part of this version number are 0 to 65535.

You can also specify a range of versions in the following format: n.n.n.n - n.n.n.n

newVersion: Required attribute. Specifies the version of the assembly to use instead of the originally requested version in the format: n.n.n.n

This value can specify an earlier version than oldVersion.