建议一种自动更新我的 C# 程序的方法

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/555118/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 07:59:53  来源:igfitidea点击:

Suggest a method for auto-updating my C# program

c#auto-update

提问by

I need to keep a program I've written up to date, this will happen frequently over the next year or so, this will need to be done over the Internet. Where would you suggest I start, are there any common techniques? Any suggestions welcome.

我需要保持我编写的程序是最新的,这将在接下来的一年左右频繁发生,这需要通过 Internet 完成。你建议我从哪里开始,有什么通用的技巧吗?欢迎任何建议。

Thanks

谢谢

回答by Matt Hamilton

ClickOnceis perfect for this sort of scenario.

ClickOnce非常适合这种场景。

回答by Fritz H

ClickOnce is a good solution, but if you wish to have total control then you can roll-your-own. I would suggest polling a webservice to find if there are later versions available, downloading required files to a side-by-side directory, and using a launcher (or updating a shortcut) to automatically launch the latest version.

ClickOnce 是一个很好的解决方案,但如果您希望拥有完全控制权,那么您可以自行解决。我建议轮询网络服务以查找是否有更高版本可用,将所需文件下载到并排目录,并使用启动器(或更新快捷方式)自动启动最新版本。

This is a little complicated, but caters for situations where the application may be running, and can therefore not be overwritten.

这有点复杂,但适合应用程序可能正在运行的情况,因此不能被覆盖。

回答by synhershko

Fairly well is not good enough :)

相当好还不够好:)

NAppUpdate is an open-source library I wrote to address just this. The general idea is to have the greatest flexibility, at the lowest overhead possible.

NAppUpdate 是我写的一个开源库来解决这个问题。总体思路是以尽可能低的开销获得最大的灵活性。

So, integration is super-easy, and the library does pretty much everything for you, including synchronizing operations. It is also highly flexible, and lets you determine what tasks to execute and on what conditions - you set the rules. Last by not least is the support for any updates source (web, BitTorrent, etc) and any feed format - whatever is not implemented you can just write by yourself.

因此,集成非常简单,该库几乎可以为您完成所有工作,包括同步操作。它也非常灵活,可以让您确定要执行的任务以及在什么条件下执行 - 您可以设置规则。最后同样重要的是支持任何更新源(网络、BitTorrent 等)和任何提要格式 - 任何未实现的都可以自己编写。

Cold updates (requiring an application restart) are also supported, and done automatically unless "hot-swap" is specified for the task.

冷更新(需要重新启动应用程序)也受支持,除非为任务指定了“热交换”,否则会自动完成。

This all boils down to one DLL, less than 70kb in size.

这一切都归结为一个 DLL,大小不到 70kb。

More details at http://www.code972.com/blog/2010/08/nappupdate-application-auto-update-framework-for-dotnet/

更多详情请访问http://www.code972.com/blog/2010/08/nappupdate-application-auto-update-framework-for-dotnet/

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

代码位于http://github.com/synhershko/NAppUpdate(在 Apache 2.0 许可下获得许可)

回答by Shaikh Mohd. Nadeem

There is this great framework called NetSparkleand also this DotNetUpdater

有一个很棒的框架叫做NetSparkle,还有这个 DotNetUpdater

I haven't used them yet but hope to do so very soon. You can try it out.

我还没有使用它们,但希望尽快使用。你可以试试看。