如何使用补丁更新应用程序文件?

发布于 2024-08-28 06:22:13 字数 885 浏览 9 评论 0原文

我对任何自动更新解决方案都不感兴趣,例如 ClickOnce 或 MS Updater Block。对于任何想问为什么不这样做的人:我已经在使用这些并且它们没有任何问题,我只是想了解任何有效的替代方案。

我想发布补丁=小差异,这些差异将以尽可能小的增量修改部署的现有文件。不仅代码需要打补丁,资源文件也需要打补丁。修补正在运行的代码可以通过维护部署的两个单独的同步副本来完成(不需要对正在运行的可执行文件进行即时更改)。

应用程序本身可以进行 xcopy 部署(以避免 MSI 自动更正修改的文件或破坏 ClickOnce 签名)。

  • 我想了解如何处理不同版本的补丁(例如,发布了一个修复一个错误的补丁,后来发布了另一个修复另一个错误的补丁(在同一文件中) - 用户可能有这些的任意组合第三个补丁 - 在文本文件中,这可能很容易实现,但是可执行文件怎么样?(本机 Win32 代码与 .NET,有什么区别吗?)

  • 如果第一个问题太难解决或无法解决可执行文件,我至少想了解是否有解决方案通过串行修订版实现简单的修补 - 为了安装修订版 5,用户必须安装所有以前的修订版以确保部署的有效性。

  • 补丁可以作为可从网站下载的文件发布 - 不需要直接从正在运行的应用程序提供自动补丁功能。

是否有任何现有的解决方案可以实现此目的?

注意:SO 上有一些问题可能看起来重复,但没有一个有好的答案。

这个问题是关于Windows平台的,最好是.NET。

到目前为止,wyUpdate似乎最适合这个问题。仍然对替代品感兴趣。

I am not interested in any auto update solution, such as ClickOnce or the MS Updater Block. For anyone feeling the urge to ask why not: I am already using these and there is nothing wrong with them, I would just like to learn about any efficient alternatives.

I would like to publish patches = small differences that will modify existing files of the deployment with the smallest possible delta. Not only code needs to be patched, but also resource files. Patching the running code can be accomplished by maintaining two separate synchronized copies of the deployment (no on the fly changes to the running executable are required).

The application itself can be xcopy deployed (to avoid MSI auto-correcting the modified files or breaking ClickOnce signatures).

  • I would like to learn how to handle different versions of patches (e.g. there is a patch issued that fixes one error and later another patch that fixes another error (in the same file) - users may have any combination of these and there comes a third patch - in text files, this may be easy to implement, but how about executable files? (native Win32 code vs. .NET, any difference?)

  • If the first problem is too hard to solve or unsolvable for executables, I would like to at least learn if there is a solution that implements simple patching with serial revisions - in order to install revision 5, user must have all previous revisions installed to ensure validity of the deployment.

  • The patches can be issued as downloadable files from a website - no auto-patching functionality directly from a running application is required.

Are there any existing solutions to accomplish this?

NOTE: There are a few questions on SO that may seem like duplicates, but none with a good answer.

This question is about the Windows platform, preferably .NET.

So far, wyUpdate seems to fit this problem best. Still interested in alternatives.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不回头走下去 2024-09-04 06:22:13

您将无法创建一个可以应用于该程序的多个版本的二进制补丁,因此以下情况将不可能发生:

      org+p1
     /      \
    + p1     +p2    <-- note, p2 is the same patch both places
   /          \
original       org+p1+p2
   \          /
    + p2     +p1    <-- ie. the p2 on this line is the same as the one above
     \      /
      org+p2

您将出现这种情况:

      org v.2
     /      \
    +p1      +p4    <-- note, different patches now
   /          \
org v.1        org v.4
   \          /
    +p2      +p3
     \      /
      org v.3

如果您想允许您的用户可以挑选他们想要应用的修复程序。是的,这可以通过文本文件来完成,毕竟,这就是大多数源代码控制工具的分支和合并的工作方式,但它们的工作基础是您可以在文件中插入和删除内容,而不会影响文件的其余部分,并且不适用于可执行文件。

注意:一种特殊情况是替换字节的修复,但不会在文件中插入或删除任何内容。只要多个此类修复不重叠,就可以挑选您想要应用的修复。然而,这样的补丁非常罕见。

正如您在问题中暗示的那样,您应该使用串行时间线,可能对现有版本进行单个修补程序,因此您可能会使用这个:

                                      +-- most up to date version
                                      |            
                                      v
org v.1         org v.3             org v.4
   \           /       \           /
    +p1       +p2       +p3       +p4
     \       /           \       /
      org v.2             org v.4
       \
        +p1.1
         \
          org v.2 hotfix 1

至于实际代码,我有一个 diff/patch 实现,但它可能是远非最佳。目前,为任何相当大的文件生成补丁文件都需要大量时间。这些补丁相当小,但我敢说其他算法会产生更好的补丁。使用 bsdiff 和 bspatch 进行的示例测试会生成较小的补丁。

但是,代码是 这里如果你想玩一下。它是一个更大的类库的一部分,我不记得只编译二进制补丁类需要它的多少(库的其余部分),但它都在那里。您要使用的类是 Delta2 类。

You will not be able to create one binary patch that can apply to multiple versions of the program, so the following scenario will not be possible:

      org+p1
     /      \
    + p1     +p2    <-- note, p2 is the same patch both places
   /          \
original       org+p1+p2
   \          /
    + p2     +p1    <-- ie. the p2 on this line is the same as the one above
     \      /
      org+p2

You will instead have this scenario:

      org v.2
     /      \
    +p1      +p4    <-- note, different patches now
   /          \
org v.1        org v.4
   \          /
    +p2      +p3
     \      /
      org v.3

You should easily see how complex this becomes if you want to allow your users to cherrypick the fixes they want to apply. Yes, this can be done with text files, after all, that's how branching and merging works with most source control tools, but they work on the basis that you can insert and delete stuff in files without compromising the rest of the file, and that doesn't work with an executable.

Note: A special case is fixes that replace bytes, but doesn't insert or delete anything from the file. As long as multiple such fixes doesn't overlap it would be possible to cherrypick which ones you want to apply. However, such patches are very rare.

You should, as you've hinted in your question, work with a serial timeline, possibly with single hotfixes to existing versions, so you might have this instead:

                                      +-- most up to date version
                                      |            
                                      v
org v.1         org v.3             org v.4
   \           /       \           /
    +p1       +p2       +p3       +p4
     \       /           \       /
      org v.2             org v.4
       \
        +p1.1
         \
          org v.2 hotfix 1

As for actual code, I have a diff/patch implementation, but it is probably far from optimal. It currently takes a lot of time to produce the patch files for any sizable file. The patches are fairly small, but I dare say other algorithms will produce better patches. Sample tests with bsdiff and bspatch produces smaller patches.

However, the code is here if you want to play with it. It is part of a larger class library and I can't remember how much of it (the rest of the library) you need to compile just the binary patch classes, but it's all there. The class you want to use is the Delta2 class.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文