对于 ASP.NET 应用程序,Web.Config 文件中有几个条目,格式如下:
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.6.5135" newVersion="1.6.5135" />
</dependentAssembly>
这些库以 NuGet 包的形式出现。
现在每次更新我的 20 多个 NuGet 包时,我都会执行以下操作:
- 一键更新所有包。
- 在浏览器中打开应用程序。
- 查看类似 this one 的错误.
- 打开我的 Web.Config,找到绑定(bind)重定向条目。
- 查找程序集的最新版本。
- 修改我的 web.config。
- 更新所有其他具有绑定(bind)重定向的已更新 NuGet 包的步骤 2…6。
这非常烦人。
我的问题:
有没有办法告诉 bindingRedirect
entry始终使用最新版本?
例如像这样的东西:
<bindingRedirect oldVersion="0.0.0.0-*" newVersion="*" />
(使用通配符来告诉最新版本)
我最接近的是这样的:
<bindingRedirect oldVersion="0.0.0.0-9.9.9.9" newVersion="1.6.5135" />
(只指定一次最新版本)
最佳答案
不幸的是,答案是否定的。查看bindingRedirect element on MSDN .
引用:
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.
关于c# - 我可以告诉 bindingRedirect 始终使用最新的可用版本吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24497259/