简体   繁体   English

您如何使用NSIS制作更新安装程序?

[英]How do you make an update installer with NSIS?

I currently have a project with an installer I made with NSIS, but I would like to have an update to new versions that only has the changed files and will show a changelog. 我目前有一个使用NSIS制作的安装程序的项目,但是我想更新到仅包含已更改文件并显示变更日志的新版本。 The target platform is windows. 目标平台是Windows。 What methods/suggestions do you have to do this? 您必须采取什么方法/建议?

You might want to reconsider using NSIS. 您可能需要重新考虑使用NSIS。 If you are into patching and distributing updates you will probably get the most benefit from using an installer technology that utilises the Windows Installer capabilities (msiexec). 如果您要修补和分发更新,则可能会受益于使用利用Windows Installer功能(msiexec)的安装程序技术。

NSIS is basically a program that runs and does what you want whereas a Windows Installer type installer forces you to split your application into features and components which can be managed by the windows installer msi service. NSIS基本上是一个可以运行并执行所需功能的程序,而Windows Installer类型的安装程序会强制您将应用程序拆分为可由Windows Installer msi服务管理的功能和组件。 MSI will track things like what versions of products you have installed, whether running the installer again will run in maintenance mode, whether you are allowed to install 2 products of different versions, whether a patch can be applied to a particular version of a product or any other question relating to updates and installs. MSI将跟踪诸如您已安装产品的哪个版本,是否再次运行安装程序将在维护模式下运行,是否允许您安装2个不同版本的产品,是否可以将补丁程序应用于产品的特定版本或诸如此类的信息。与更新和安装有关的任何其他问题。

Basically most of the stuff you are requesting will be available out-of-the-box if you change to a Windows Installer technology. 基本上,如果您要更改为Windows Installer技术,则可以立即使用您要求的大多数内容。 Whereas if you use NSIS (which doesn't use Windows Installer technology) then you will have to implement it all yourself. 而如果您使用NSIS(不使用Windows Installer技术),则必须自己全部实现。

Just as an example there is a pretty comprehensive installer builder called AdvancedInstaller ( http://www.advancedinstaller.com/ ) that sounds like what you want. 例如,有一个非常全面的安装程序生成器,称为AdvancedInstaller( http://www.advancedinstaller.com/ ),听起来像您想要的。 Alternatively, if you want to spend the rest of your life trawling forums and newsgroups then there is an open source product called WiX that does something similar ;) 另外,如果您想度过余生,在论坛和新闻组中度过一生,那么有一个名为WiX的开源产品可以完成类似的工作;)

In spite of my previous comment I have written a 5000 line installer using NSIS with 13 custom pages. 尽管有我之前的评论,我还是使用带有13个自定义页面的NSIS编写了5000行安装程序。 I have even looked at patching and it's a bit of a hack. 我什至看过补丁程序,这有点骇人听闻。 The main bit of advice is to make sure you are patching the version you think you are patching then use one of the patching plugins available. 建议的主要内容是确保正在修补您认为要修补的版本,然后使用可用的修补插件之一。

There are several patching technologies that compare files and produce patch change files and the NSIS code required to "install" them. 有几种修补技术可以比较文件并生成补丁更改文件以及“安装”它们所需的NSIS代码。 I have found that NSIS Patch Gen did what I wanted pretty well with the least amount of hassle. 我发现NSIS Patch Gen以最少的麻烦就很好地完成了我想要的工作。 The documentation is a bit thin but once you figure it out you think "Oh yeh". 文档有点薄,但是一旦弄清楚了,您就会觉得“哦,是的”。

You are probably going to have a little bit of trouble with an automatically generated Change Log. 自动生成的变更日志可能会给您带来一些麻烦。 I would suggest that you create the Change Log yourself (or at least add the extra changes to it with each application change you make) and just include it as if it was a normal application file and let the patch generator update it. 我建议您自己创建更改日志(或至少对您所做的每个应用程序更改添加额外的更改),并像正常应用程序文件一样包含它,并让补丁生成器对其进行更新。

http://sourceforge.net/projects/nsispatchgen/ http://sourceforge.net/projects/nsispatchgen/

One possible way would be to store an XML file on your download server that has each released version and a list of files that changed for each release. 一种可能的方法是在下载服务器上存储一个XML文件,该文件具有每个已发布的版本以及每个版本已更改的文件列表。 The installer would write a registry key on install of the version of files it installed. 安装程序将在安装安装的文件版本时写一个注册表项。

Then, on update, the installer downloads and parses the XML file, and finds any nodes that have higher version numbers than what is currently installed. 然后,在更新时,安装程​​序将下载并解析XML文件,并查找所有版本号高于当前安装版本的节点。 You display all the files in a text box on an installer page, and when the user confirms, the installer downloads all the files, and then updates the registry to the latest version. 您将所有文件显示在安装程序页面上的文本框中,当用户确认时,安装程​​序将下载所有文件,然后将注册表更新为最新版本。

are you familiar with cURL? 您熟悉cURL吗? http://www.shininglightpro.com/products/Win32OpenSSL.html http://curl.haxx.se/download.html#openssl http://www.shininglightpro.com/products/Win32OpenSSL.html http://curl.haxx.se/download.html#openssl

it will download any protocol, and you can use it to download your files. 它会下载任何协议,您可以使用它来下载文件。 it's a commandline app. 这是一个命令行应用程序。

in the installer, schedule a program which should check first to see if the main program is running or not and quit if it is running if not, calls curl to download a batch file from your site with the updates, then runs the batch file. 在安装程序中,安排一个程序,该程序应首先检查主程序是否正在运行,如果未运行则退出,然后调用curl从您的站点下载包含更新的批处理文件,然后运行该批处理文件。
the batch file it downloads updates the app by downloading the correct files using curl. 它下载的批处理文件通过使用curl下载正确的文件来更新应用程序。 the process should run maybe every 2 weeks or once a month, depending on how often you update. 该过程可能每2周运行一次,或者每月运行一次,具体取决于您更新的频率。

the uninstall part of the installer should be capable of removing all parts of the app in question,including any updates. 安装程序的卸载部分应能够删除有问题的应用程序的所有部分,包括所有更新。 this can be accomplished by removing all files from that subdir of program files. 这可以通过从程序文件的该子目录中删除所有文件来实现。

RMDir /r /REBOOTOK '$INSTDIR'
RMDir /r /REBOOTOK "$SMPROGRAMS\$StartMenuFolder"
Delete '$SMPROGRAMS\$StartMenuFolder\gpl3license.lnk'
Delete '$SMPROGRAMS\$StartMenuFolder\readme.lnk'
Delete '$SMPROGRAMS\$StartMenuFolder\${PRODUCT_TITLE}.lnk'
DeleteRegKey HKCU "Software\Your major subkey\${PRODUCT_NAME}"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
DeleteRegKey /ifempty HKCU "Software\${PRODUCT_NAME}"

PRODUCT_NAME is a !define I made because I use these nsi files like a template. PRODUCT_NAME是我定义的!因为我将这些nsi文件用作模板。 this is only a piece of the installer file's uninstaller section. 这只是安装程序文件的卸载程序部分的一部分。

I've been able to create a patch updater program for my Windows app (a CLI which uses NSIS as its installer) by releasing the app to my personal CDN (or some hosting platform) and taking advantage of Node.js modules like path to replace the binary (using a similar procedure to equinox.io ) with a given version from the CDN and winreg to update the Windows Registry accordingly. 通过将应用发布到我的个人CDN(或某些托管平台)并利用Node.js模块(如path ),我已经能够为Windows应用(使用NSIS作为其安装程序的CLI)创建补丁更新程序。用CDN和winreg的给定版本替换二进制文件(使用与equinox.io类似的过程)以相应地更新Windows注册表。 Since I've namespaced my Windows Registry key, the uninstaller still works for it. 由于已为Windows注册表项命名空间,因此卸载程序仍然可以使用。

If anyone wants more details on this, please ask. 如果有人需要更多详细信息,请询问。 I'm happy to help. 我很乐意提供帮助。

Some compilers like Delphi make a lot of changes in the final executable even if you change a little part of your code. 诸如Delphi之类的某些编译器在最终可执行文件中进行了很多更改,即使您只更改了一部分代码。

So first you should see if it worth patching. 因此,首先您应该看看是否值得修补。

Another consideration is patching by itself. 另一个考虑因素是打补丁。 Patching maybe blocked by some Anti Virus Software specially in some system folders. 修补程序可能被某些系统文件夹中的某些防病毒软件阻止了。

and finally incremental patching data size can grow beyond the original files. 最后,增量修补数据的大小可能会超出原始文件。

Based on above subjects I don't suggest you patching. 基于以上主题,我建议您不要打补丁。 Use full installers instead 改用完整的安装程序

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM