.NET 的自动更新库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/691663/
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-09-03 12:25:24  来源:igfitidea点击:

Auto-update library for .NET?

.netauto-update

提问by Andrew Grant

On the Mac there's a really nice library called Sparklethat programs can use to implement the checking/install functionality for auto-updates.

在 Mac 上,有一个非常好的库,称为Sparkle,程序可以使用它来实现自动更新的检查/安装功能。

Is there anything similar out there for .NET? Or just regular Win32?

.NET 有没有类似的东西?还是只是普通的 Win32?

采纳答案by Raj

ClickOncehas its own security limitations (understandbly so). If you want the full power and control of a Windows application then go with the .NETapplication updatercomponent. It works like a charm and has even been used by Microsoft internally for their .NET based game (I don't remember the game name though).

ClickOnce有其自身的安全限制(可以理解)。如果您想要 Windows 应用程序的全部功能和控制,那么请使用.NET应用程序更新程序组件。它就像一种魅力,甚至被微软内部用于他们基于 .NET 的游戏(虽然我不记得游戏名称)。

回答by Wyatt O'Day

Let me start by saying we offer a complete updating solution which includes:

首先让我说我们提供了一个完整的更新解决方案,其中包括:

wyUpdate handles all of the Vista/Windows 7 UAC problems and all the file permission problems that inevitably pop up when you're trying to update complex software.

wyUpdate 可以处理所有 Vista/Windows 7 UAC 问题以及在您尝试更新复杂软件时不可避免地出现的所有文件权限问题。

That being said, if you want to build your own updater here are some tips:

话虽如此,如果您想构建自己的更新程序,这里有一些提示:

Building your own updater

构建自己的更新程序

A good place to start is the wyUpdate C# source codeI mentioned above. You can cannibalize it and use it for your own purposes. Some of the algorithms it contains:

一个很好的起点是我上面提到的wyUpdate C# 源代码。您可以蚕食它并将其用于自己的目的。它包含的一些算法:

  • Full Windows Vista / Windows 7 UAC support
  • Ability for limited users to check and then update if they have credentials
  • Support for wonky corporate inernet. (If you've ever worked with a corporation this is a real problem).
  • Quick extracting, patching, and installing of files.
  • Registry support.
  • Roll back files & registry on error or cancellation by the user
  • Self-update (no files left behind)
  • 完整的 Windows Vista / Windows 7 UAC 支持
  • 能够让受限用户检查并更新他们是否拥有凭据
  • 支持不稳定的企业互联网。(如果你曾经与一家公司合作过,这是一个真正的问题)。
  • 快速提取、修补和安装文件。
  • 注册表支持。
  • 在用户出错或取消时回滚文件和注册表
  • 自我更新(不留下任何文件)

We also have the file specifications here.

我们这里也有文件规范

Automatic updating

自动更新

Since being automatic is a requirement let me tell you how we do it with our AutomaticUpdater control.

由于自动是一项要求,让我告诉您我们如何使用AutomaticUpdater 控件做到这一点。

We use named pipes to communicate between the standalone updater (wyUpdate) and the Automatic Updater control sitting on your program's form. wyUpdate reports progress to the Automatic Updater, and the Automatic Updater can tell wyUpdate to cancel progress, to start downloading, start extracting, etc.

我们使用命名管道在独立更新程序 (wyUpdate) 和位于程序窗体上的自动更新程序控件之间进行通信。wyUpdate 向自动更新器报告进度,自动更新器可以告诉 wyUpdate 取消进度、开始下载、开始解压等。

This keeps the updater separate from your application.

这使更新程序与您的应用程序分开。

In fact, the exact named pipes C# code we use is included in an article I wrote a little while back: Multi-process C# app like Google Chrome.

事实上,我们使用的确切命名管道 C# 代码包含在我不久前写的一篇文章中:Multi-process C# app like Google Chrome

回答by Jonathan Allen

ClickOnceis my preferred method. It has some warts, but it comes with Visual Studio and works reasonably well.

ClickOnce是我的首选方法。它有一些问题,但它与 Visual Studio 一起提供并且运行良好。

回答by Jeremy Sena

ClickOnce is heavily used, but you can do what I did for a large application and try these:

ClickOnce 被大量使用,但您可以按照我为大型应用程序所做的操作并尝试以下操作:

I tinkered with the logic a bit and built what I thought was a better XML update file. Now, when I need to update the clients, I just post the new EXE files or DLL files and set the correct versions in the public XML file. My application detects the newer versions if it is older and updates itself. If you are doing this on Windows Vista, you need to prompt for administrator permissions so that Program Files can be written to (if you install there).

我稍微修改了逻辑并构建了我认为更好的 XML 更新文件。现在,当我需要更新客户端时,我只需发布新的 EXE 文件或 DLL 文件并在公共 XML 文件中设置正确的版本。我的应用程序会检测到较旧的版本并自行更新。如果您在Windows Vista上执行此操作,则需要提示管理员权限,以便可以写入程序文件(如果您在那里安装)。

You can also easily convert this to C# using C#/VB.NET Converter.

您还可以使用C#/VB.NET Converter轻松地将其转换为 C# 。

回答by Lou Zell

I just went through the process of doing this and used NetSparkle.

我刚刚经历了这样做的过程并使用了NetSparkle

It worked as advertised for a Windows Formsapplication with an MSIinstaller that overwrites the previous version. I'm very glad I found it too -- I was about to roll my own. Am I the only one making really simple .NET applications? Mostly everything I looked at seemed like a complete overkill.

它的工作原理Windows 窗体应用程序的广告一样,其MSI安装程序覆盖了以前的版本。我很高兴我也找到了它——我正要自己动手。我是唯一一个制作非常简单的 .NET 应用程序的人吗?大多数情况下,我看到的一切似乎完全是矫枉过正。

回答by Eric Bole-Feysot

I didn't try NetSparkle yet (I will later), but it seems it's what you're looking for.

我还没有尝试 NetSparkle(稍后我会尝试),但它似乎是您正在寻找的。

NetSparkleis an easy-to-use software update framework for .NET developers on Windows, Mac or Linux. It was inspired by the Sparkleproject for Cocoadevelopers and the WinSparkleproject (a Win32port).

NetSparkle是一个易于使用的软件更新框架,适用于 Windows、Mac 或 Linux 上的 .NET 开发人员。它的灵感来自于面向Cocoa开发人员的Sparkle项目和WinSparkle项目(一个Win32端口)。

回答by Eric Bole-Feysot

I think WyBuildis good Sparkle alternative )

我认为WyBuild是很好的 Sparkle 替代品)

回答by Luke Quinane

DotNetAutoUpdate

点网自动更新

I've implemented a library to do this called DotNetAutoUpdate(original name eh?). It aims to be:

我已经实现了一个名为DotNetAutoUpdate的库来执行此操作(原始名称是吗?)。它的目标是:

  • Simple to use
  • Simple to setup
  • Secure
  • 使用简单
  • 设置简单
  • 安全的

回答by synhershko

Here's an open-source solution I wrote to address specific needs we had for WinForms and WPF apps. The general idea is to have the greatest flexibility, at the lowest overhead possible.

这是我编写的一个开源解决方案,用于解决我们对 WinForms 和 WPF 应用程序的特定需求。总体思路是以尽可能低的开销获得最大的灵活性。

So, integrationis 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 make the rules (or use some that are there already). Last but not least is the support for any update source(web, BitTorrent, etc) and any feed format- whatever is not implemented you can just write for yourself.

因此,集成非常简单,该库几乎可以为您完成所有工作,包括同步操作。它也非常灵活,可以让您确定要执行的任务以及在什么条件下执行 - 您可以制定规则(或使用一些已经存在的规则)。最后但并非最不重要的是对任何更新源(网络、BitTorrent 等)和任何提要格式的支持- 无论没有实现,您都可以自己编写。

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

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

This 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 许可下获得许可)

I plan on extending it more when I get some more time, but honestly you should be able to quickly enhance it yourself for whatever it currently doesn't support.

当我有更多时间时,我计划对其进行更多扩展,但老实说,您应该能够针对当前不支持的任何内容快速增强它。

回答by spinner_den_g

There is a really nice utility called Updater. It looks like it is written in Cor C++. I have been able to configure the XML files and load them to the production server, and then I can have the Updater Run and check the XML file for a different version and download a new update install package that I built using the Nullsoft Scriptable Install System(NSIS).

有一个非常好的实用程序,称为Updater。看起来它是用CC++编写的。我已经能够配置 XML 文件并将它们加载到生产服务器,然后我可以让更新程序运行并检查不同版本的 XML 文件,并下载我使用Nullsoft Scriptable Install System构建的新更新安装包(国家统计局)。