Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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)

like image 283
Uwe Keim Avatar asked Jun 30 '14 19:06

Uwe Keim


1 Answers

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.

like image 120
Bringer128 Avatar answered Nov 07 '22 00:11

Bringer128