应用程序启动器如何自我更新?

发布于 2024-12-28 06:14:10 字数 335 浏览 0 评论 0原文

启动器在游戏中最常见。想想《英雄联盟》、《星际争霸 II》或几乎任何 MMO。在开始实际游戏之前,您有一个小型启动器应用程序来负责更新和修补。

我想通过我正在开发的特定非游戏应用程序来推动这个方向。启动器的概念非常有意义:它检查更新,替换适当的二进制文件/库,可能运行完整性检查,然后启动应用程序。但是,启动器如何自我更新?这往往是一个罕见的事件,但它是如何做到的呢?启动器实际上只是重写当前运行的二进制文件吗?或者下载后是否有某种交换步骤?我需要能够向启动器推出(罕见的)更新(特别是如果我在启动器中发现一些错误)。

我的特定项目将使用 C#,但我也对概念上类似的 C++ 和/或 Java 解决方案感兴趣,以供将来参考。

Launchers are most common in games. Think of League of Legends, Starcraft II, or almost any MMO out there. Before starting the actual game, you have a small launcher app that takes care of updates and patching.

I want to move this direction with a particular non-game application I am developing. The concept of the launcher makes perfect sense: it checks for updates, replaces the appropriate binaries/libraries, maybe runs an integrity check, and launches the application. However, how do launchers update themselves? This tends to be a rare event, but how is it done? Does the launcher literally just write over the very binary it is currently running from? Or is there some kind of swap step after the download? I need to be able to push out (rare) updates to the launcher (especially if I discover some bug in my launcher).

My particular project will be in C#, but I am interested in conceptually similar C++ and/or Java solutions as well for future reference.

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

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

发布评论

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

评论(3

梦里泪两行 2025-01-04 06:14:10

我从未尝试过,但这就是我的猜测(假设您无法覆盖正在执行的文件。如果可以,这一切都会更简单)

Updater A checks if its the newest version
If launcher isnt the newest version
    Download the differences (to save bandwidth) to file B
    Apply the delta to own code into file C
    Launch file C.
    Close
If file C exists (update happened recently)
    Try to delete C  (update was previous launch, delete temporary file)
    If delete fails  (We are C, means A is out of date)
        Copy C over A  (update launcher)
        Note that you can keep going, dont have to restart even though we are C.
If game isnt newest version
    Download the differences (to save bandwidth) to file B
    Apply the delta to game into file D
    delete game
    Rename D -> game
Run game

André Caron 向我展示了使用 事务文件 IO

I've never tried, but this is what I would guess (assuming you can't overwrite a file being executed. If you can, this is all simpler)

Updater A checks if its the newest version
If launcher isnt the newest version
    Download the differences (to save bandwidth) to file B
    Apply the delta to own code into file C
    Launch file C.
    Close
If file C exists (update happened recently)
    Try to delete C  (update was previous launch, delete temporary file)
    If delete fails  (We are C, means A is out of date)
        Copy C over A  (update launcher)
        Note that you can keep going, dont have to restart even though we are C.
If game isnt newest version
    Download the differences (to save bandwidth) to file B
    Apply the delta to game into file D
    delete game
    Rename D -> game
Run game

André Caron has shown me that the swap trick is done better with transactional file IO.

单身狗的梦 2025-01-04 06:14:10

基本上,启动器会检查自身是否有更新版本,如果有,则启动任务以获取新版本,然后执行它,然后关闭。

鉴于更新程序应用程序很小并且加载速度很快,您可以让它检测、下载、弹出一个对话框说有新版本,并且在旧版本关闭和新版本运行时几乎不会闪烁。

Basically the launcher checks to see if there is a newer version of it self, and if so kicks off a task to get the new version and then executes it and then closes.

Given the updater app is small and loads up quick, you can have it detect, download, stick up a dialog to say there's a new version, and barely flicker as the old version closes and the new one runs up.

对不⑦ 2025-01-04 06:14:10

如果您身处 .NET 世界,有一种名为“Click Once”的部署策略。创建它是为了解决您所描述的问题...

ClickOnce 是一种部署技术,允许您创建基于 Windows 的自动更新应用程序,这些应用程序可以通过最少的用户交互来安装和运行。 ClickOnce 部署克服了部署中固有的三个主要问题:

来源:点击一次

在开始实施这一策略之前,我建议先研究一下它的优点和缺点,因为有狂热的粉丝和反对者。

简而言之,您将新版本上传到网站(应用程序配置为了解该网站)。在启动时,应用程序会检查站点,如果有更新,则会向用户提供一个对话框。当用户选择应用更新时,应用程序将停止,同时激活“单击一次”组件以应用更改。然后,该组件重新启动可执行文件,这对最终用户来说都是无缝操作......

If you are in the .NET world, there is a deployment strategy called 'Click Once'. This was created to solve the problem you have described...

ClickOnce is a deployment technology that allows you to create self-updating Windows-based applications that can be installed and run with minimal user interaction. ClickOnce deployment overcomes three major issues inherent in deployment:

Source: Click Once

Before embarking on this strategy, I suggest researching its pros and cons because there are avid fans and detractors.

Briefly, you upload new versions to a web site (which the application is configured to know about). At start up time, the application checks the site and if there's an update offers the user a dialog. When the user elects to apply the update, the application is stopped and simultaneously a 'click once' component is activated to apply the changes. The component then restarts the executable and this all appears as a seamless operation to the end user...

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