使用 Google 代码自动更新

发布于 2024-11-03 10:31:42 字数 617 浏览 1 评论 0原文

我想让我的软件自动更新,但我没有丰富的网页设计技能,也没有任何可用的网站/在线托管。我想用 C#/WPF 来做。

所以我想知道是否有一种方法可以使用谷歌代码创建自动更新服务,一些干净的东西。我想我不是第一个想到这个的人。

我会这样做:

1)使用网络浏览器(静默)并导航到我的谷歌代码页。在该页面上,我将放置一个字段,在其中输入最新版本号。 (我需要以某种方式在页面内容中找到该数字)。

2) 我将该数字与当前安装的版本进行比较(例如,我可以将 CURRENT_VER_NUMBER 放入软件文件夹中的 *.txt 中)。

3)如果我断定有新版本可用,我会从我的谷歌代码项目的“下载”选项卡下载它,解压缩它,覆盖安装目录中的文件,然后重新启动应用程序。

首先,这样可以吗?当我想象它时,这听起来像是肮脏的代码。

然后,我不知道如何导航到下载选项卡,更不知道如何选择那里的最新版本(也许通过执行非常严格的文件命名)并下载它。

最后但并非最不重要的一点是,如果应用程序已经在运行以执行更新检查,我无法在不退出应用程序的情况下覆盖文件,这是否意味着我必须制作某种执行检查的“主应用程序”在启动我的软件之前?听起来也很脏=/

非常欢迎任何输入,

祝你有美好的一天。

I want to make my software autoupdate itself, but I don't have extensive webdesign skills, nor any available website/online hosting. I want to do it in C#/WPF.

So I was wondering if there could be a way to make an autoupdate service using google code, something clean. I'm guessing I'm not the first one to think of it.

I'd do it this way:

1) Use a WebBrowser (silently) and navigate to my google code page. On that page I'd put a field where I enter the latest version number. (I need to somehow find that number in the page's content).

2) I compare that number to the version currently installed (I could put the CURRENT_VER_NUMBER in a *.txt in the software's folder for example).

3) If I conclude that a new version is available, I download it from the "Downloads" tab of my google code project, unzip it, overwrite the files in the installation directory, and restart the app.

First of all, would that work fine? When I imaginate it, it sounds like dirty code.

Then, I wouldn't know how to navigate to the downloads tab, even less how to select the latest version there (maybe by doing a very strict file naming), and download it.

And last but not least, If the application is already running in order to perform the update check, I couldn't overwrite the files without quitting the application, does that mean I have to make some kind of "master app" that performs the check before starting my software? Sounds dirty too =/

Any input is very welcome,

Have a nice day.

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

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

发布评论

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

评论(3

扶醉桌前 2024-11-10 10:31:42

我建议您看一下 ClickOnce。它不需要您创建网页。您只需要托管 2 个文件:一个 .manifest 文件,其中包含有关您的应用程序的信息(版本、名称和包含您的应用程序的包的链接)以及应用程序包的最新版本。您唯一需要做的就是托管这 2 个文件,并在 Google 代码页上放置指向该 .manifest 文件的链接。用户单击该链接,.net 将自动安装或检查最新版本,并在必要时进行更新。

I suggest you take a look at ClickOnce. It doesn't require you to create a webpage. You only need to host 2 files: a .manifest file that contains information about your app (version, name and a link to the package that contains your application) and the latest version of your application package. The only thing you need to do is host those 2 files and put a link on your Google Code page to that .manifest file. Users click that link and .net will automatically install or check for the latest version and update if necessary.

木格 2024-11-10 10:31:42

您可能想看看我编写并作为开源发布的库,以透明地执行此操作 - 包括用于执行实际冷更新的外部更新应用程序。请参阅 http://www.code972 .com/blog/2010/08/nappupdate-application-auto-update-framework-for-dotnet/

代码位于 http://github.com/synhershko/NAppUpdate (根据 Apache 2.0 许可证授权)

You may want to have a look at a library I wrote and released as open-source to do just that transparently - including an external update application to do the actual cold update. See http://www.code972.com/blog/2010/08/nappupdate-application-auto-update-framework-for-dotnet/

The code is at http://github.com/synhershko/NAppUpdate (Licensed under the Apache 2.0 license)

双手揣兜 2024-11-10 10:31:42

我遇到了一些问题,但总体来说并不难。我认为这种方法很干净,所以如果有人想要实现类似的目标,我会把它放在那里。

您必须查看:https://code.google.com/p/theomniscientchimp/ 提供完整源代码,当然还可以根据您的项目进行调整。

感谢您对我原来的帖子的评论,让我确信我做得对=)

I ran into a few problems, but overall it was not so hard. I think the approach is clean so I'm putting it out there if anyone ever wants to achieve something similar.

You'll have to check out: https://code.google.com/p/theomniscientchimp/ where the full source is available, and of course adjust it for your project.

Thanks for the comments on my original post, made me feel confident i was doing it right =)

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