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

爷,独闯天下 提交于 2019-12-03 15:11:37

问题


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)


回答1:


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.



来源:https://stackoverflow.com/questions/24497259/can-i-tell-bindingredirect-to-always-use-the-latest-available-version

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!