我不“明白”程序如何自我更新。我怎样才能更新我的软件?

发布于 2024-08-11 06:04:22 字数 305 浏览 3 评论 0原文

假设我创建了一个 .exe 文件,一切都很顺利。太棒了,它有效。

假设我在软件上开发了一项新功能,并且我希望它可供已经拥有旧版本的人使用,我怎样才能让软件找到我的新版本,修补它,然后继续它的业务。

我似乎无法思考这个问题。

谢谢。

编辑: 对于造成的混乱,我深表歉意,但我的意思是一个更代码明智的答案。我的代码中有什么特殊的东西我应该允许更新吗?

例如,如果我想添加一个新功能,我如何向已经打包的 .exe 添加“方法”? :S 那让我旋转起来。

Say I make an .exe file and everything is peachy. Wonderful it works.

Say I worked on a new feature on the software and I want it to be available for people who already have the older version, how can I make the software find my new version, patch it, and then go about it's business.

I can't seem to wrap my head around the issue.

Thank you.

EDIT:
I'm sorry for the confusion, but I was meaning a more code-wise answer. Is there something special in my code I should have to allow updating?

For example, if I want to add a new feature, how can I add a "method" to an already packaged .exe? :S That has me in a swivel.

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

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

发布评论

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

评论(9

別甾虛僞 2024-08-18 06:04:22

通常过程如下:

  • 用户启动应用程序
  • 应用程序启动“更新程序”(另一个程序)
  • 更新程序从 Internet 检索是否存在更新版本
  • 如果存在,建议用户更新
  • 用户接受,更新程序下载新的安装包(可以是增量的)
  • 更新程序关闭应用程序(或者更好的是,要求用户执行此操作)并启动新的安装程序
  • 安装包执行其余操作

当然您可以有很多变体,但这是基本的方法来做到这一点。

至少在 Windows 上,某些软件会安装一个始终打开的更新程序守护程序,并检查它所处理的软件的新更新(例如 GoogleUpdater)。

Usually the process is as follows:

  • the user starts the application
  • the application launches an "updater" (another program)
  • the updater retrieves from the Internet if a newer version exists
  • if that's the case, propose the user to update
  • the users accepts, the updater downloads the new install package (that can be incremental)
  • the updater shuts the application down (or better, asks the user to do it) and launches the new installer
  • the installation package do the rest

Of course you can have many variations, but this is the basic way to do it.

On Windows, at least, some software install an updater daemon that is always on and checks for new updates of the software it takes care (GoogleUpdater, for example).

冷弦 2024-08-18 06:04:22

一个流行的解决方案是实际上用一个单独的进程来替换必要的文件。

您是否注意到 Firefox 每当更新时都必须重新启动?嗯,这是因为一个单独的进程 (updater.exe) 正在下载文件,关闭 Firefox,替换文件,然后再次启动 Firefox。

编辑 当然,这假设您正在托管更新程序可以检查的在线更新列表(RSS 提要,甚至是简单的文本文件)。

A popular solution is to actually have a separate process replace the necessary files.

Have you ever noticed that Firefox has to restart whenever it updates? Well, that is because a separate process (updater.exe) is downloading the files, closing firefox, replacing the files, and then starting firefox again.

edit of course this assumes you're hosting a list of updates online that the updater program can check (an RSS feed, or even a simple text file).

握住我的手 2024-08-18 06:04:22

您需要查看 单击一旦部署

ClickOnce 是一种部署技术,使您能够创建基于 Windows 的自动更新应用程序,这些应用程序只需最少的用户交互即可安装和运行。如果您使用 Visual Basic 和 Visual C# 开发了项目,则 Visual Studio 将为使用 ClickOnce 技术部署的应用程序的发布和更新提供全面支持。

这将创建一个可下载的安装 exe,您可以将其加载到网络上。用户要么就地运行它,要么下载并运行它。这会将您的 exe 包装在代码中,该代码将检查 Web 位置(以您选择的频率)是否有更新。如果找到,它将为用户安装。

您无需对代码进行任何特殊更改即可启用此功能。除了增加版本号之外。只需照常修改和扩展您的代码、编译、构建、打包和上传即可。

需要注意的一件事是 ClickOnce 不支持安装需要管理访问权限的应用程序:

ClickOnce 部署允许非管理用户安装并仅授予应用程序所需的代码访问安全权限。

因此,如果您的应用程序需要管理员级别的访问权限才能运行甚至安装,那么它不适合您。

You need to look at Click Once Deployment.

ClickOnce is a deployment technology that enables you to create self-updating Windows-based applications that can be installed and run with minimal user interaction. Visual Studio provides full support for publishing and updating applications deployed with ClickOnce technology if you have developed your projects with Visual Basic and Visual C#.

This creates a downloadable setup exe which you load up to the web. The user either runs this in place or downloads and runs it. This wraps your exe in the code that will check the web location (at a frequency of your choosing) for updates. If it finds one it will install it for the user.

You don't have to make any special changes to your code to enable this. beyond incrementing the version number. Just modify and extend your code as normal, compile, build, package and upload.

One thing to note is though that ClickOnce doesn't support installing applications that require administrative access:

ClickOnce deployment enables non-administrative users to install and grants only those Code Access Security permissions necessary for the application.

So if your application requires admin level access to run or even install then it's not the solution for you.

煮酒 2024-08-18 06:04:22

一个想法 - 您可以有一个加载应用程序来为您进行检查,然后如果有必要在启动之前更新主应用程序的 exe?

One idea - you could have a loader application that does the check for you, then if necessary updates the main app's exe before launching it?

酷遇一生 2024-08-18 06:04:22

对于 Windows(通常是由于 Windows 在执行时锁定 .exe 文件)

  • 软件确定需要更新
  • 软件运行打包的更新可执行文件(此时软件退出)
  • 更新将所需文件下载到某个临时文件夹
  • 更新应用补丁
  • 更新重新启动软件

For windows (generally due to windows locking the .exe file while it's being executed)

  • Software determines it needs updating
  • Software runs packaged update executable (at this point Software exits)
  • Update downloads required files into some temp folder
  • Update applies patches
  • Update restarts Software
超可爱的懒熊 2024-08-18 06:04:22

好吧,通常的方法是您的应用程序定期检查某个地方(通常在 Internet 上)是否有新版本。这可能是在每次启动时或每周一次或其他什么。

例如,您可以简单地在其中放置包含当前版本号的文本文件。如果该版本比已安装应用程序的版本更新,您可以下载更新程序(不要忘记签名并检查签名)并安装新版本。

Well, the usual way is that your application checks somewhere (usually on the Internet) regularly for new versions. This may be on every startup or once a week or whatever.

There you can simply put for example a text file containing the current version number. If that one would be newer than the version of the installed application you can download an updater (don't forget to sign and check signatures) and install the new version.

何其悲哀 2024-08-18 06:04:22

让您的应用程序偶尔通过网络向您的网络服务器发出请求。让该请求返回一个包含版本号和最新版本安装程序链接的文件。如果该版本号大于当前运行的程序认为的版本号,请让您的程序下载新的安装文件并启动它。

Make your app occasionally make a request over the web to your webserver. Have that request return a file that contains the version number and a link to the newest version of your installer. If that version number is greater than the version number the currently-running program thinks it is, have your program download the new setup file and launch it.

心碎的声音 2024-08-18 06:04:22

您不修改当前的 .exe。

您启动一个单独的进程来下载文件的新版本。新版本取代旧版本。无需修改。

You don't modify your current .exe.

You launch a separate process that downloads a new version of the file. The new version replaces the old version. No modification needed.

彩虹直至黑白 2024-08-18 06:04:22

从代码的角度来看,我喜欢采用一种方法,该方法由一个名为 IRun 的简单接口和另一个名为 IUpdated 的简单接口组成:

public interface IRun()
{
  public void Run();
}

public interface IUpdated()
{
  public void Update();
}

现在我的主应用程序将使用反射加载并“运行”一个库,从而启动真正的应用程序。

主应用程序可执行文件将执行以下步骤:

  1. 读取 updater.cfg,连接到提供的位置并检查更新程序的更新
  2. 如果有更新,
  3. 请使用反射加载 updater.dll 并启动 Update() 方法下载更新的 dll 和 updater.cfg。

update 方法对实际应用程序的更新执行相同的步骤。

最后

  1. 加载“core.dll”并启动 Run() 方法。

当然,如果您想“自己动手”,ClickOnce 实际上也是一个非常好的方法,可能更好,但控制权较少。主应用程序可执行文件足够简单,可以避免自行更新或无论如何都应该更新。

From a code point of view I like to have an approach that consists on a simple interface called IRun and another one called IUpdated:

public interface IRun()
{
  public void Run();
}

public interface IUpdated()
{
  public void Update();
}

Now my main application will just load and "run" a library using reflection which in turns launch the real application.

The main application executable will do this steps:

  1. Read updater.cfg, connect to the provided location and check for updates to the updater.
  2. If there are updates download the updated dlls and updater.cfg
  3. Using reflection load updater.dll and launch Update() method.

The update method does the same steps for updates to the actual application.

Finally

  1. Load "core.dll" and launch the Run() method.

That's of course provided you want to "do it yourself", ClickOnce is actually a very good method too, probably better but gives you less control. The main application executable is simple enough to avoid having to update it itself or should be anyway.

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