我可以告诉bindingRedirect总是使用最新的可用版本吗?

本文关键字:最新 版本 bindingRedirect 我可以 | 更新日期: 2023-09-27 18:10:56

拥有ASP。NET应用程序中有几个条目在Web中。该格式的配置文件:

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

这些库都是NuGet包。

现在,每次我更新我的20多个NuGet包时,我都会这样做:

  1. 一键更新所有包。
  2. 在浏览器中打开应用程序。
  3. 查看如下错误:
  4. 打开我的网页。配置,找到绑定重定向条目。
  5. 查找程序集的最新版本。
  6. 为所有其他带有绑定重定向的NuGet包更新步骤2…6。

这是非常恼人。

我的问题:

是否有办法告诉bindingRedirect条目总是使用最新版本?

。比如:

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

(使用通配符表示最新版本)

我遇到的最接近的是:

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

(只指定一次最新版本)

我可以告诉bindingRedirect总是使用最新的可用版本吗?

不幸的是,答案是否定的。参见MSDN上的bindingRedirect元素。

引用:

oldVersion: Required属性。

指定最初请求的程序集的版本。程序集版本号的格式为major.minor.build.revision。此版本号的每个部分的有效值为0到65535。

还可以指定一个版本范围,格式如下: n.n.n。N - N - N

newVersion:必选属性。指定要使用的程序集版本,而不是最初请求的版本,格式为:n.n.n

该值可以指定比oldVersion更早的版本。