c# - 我可以告诉 bindingRedirect 始终使用最新的可用版本吗?

标签 c# asp.net .net asp.net-mvc assembly-binding-redirect

对于 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 包时,我都会执行以下操作:

  1. 一键更新所有包。
  2. 在浏览器中打开应用程序。
  3. 查看类似 this one 的错误.
  4. 打开我的 Web.Config,找到绑定(bind)重定向条目。
  5. 查找程序集的最新版本。
  6. 修改我的 web.config。
  7. 更新所有其他具有绑定(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/

相关文章:

.net - 在 .NET WebBrowser 控件中显示 PDF 时如何隐藏 Adob​​e Reader 工具栏?

c# - C++ dll 似乎无法在 .NET 中正常工作

c# - WPF 中控件模板的动态名称?

c# - 使用 Jquery 将空字典发布到 ASP.NET MVC4 操作

c# - 修剪字符串,删除 c# 中的最后一个字符

c# - Main 方法的垃圾收集(无限循环)

c# - 比较两个对象时有条件地更改 GetHashCode()

c# - 在不创建单独项目的情况下使用 Nunit

c# - ASP.NET Imagebutton在ValidationGroup验证后执行jQuery功能

c# - 比较字符串和数组c#