自安装应用程序或单独的安装程

时间:2021-11-23 22:36:34

To get an application installed on a new computer there seems to be two major approaches in current use:

要在新计算机上安装应用程序,当前使用似乎有两种主要方法:

  1. Separate installer: Create a separate installer package that creates all directories, files, registry entries required by your application (ie an MSI, InstallSheild etc) and then finally copies your application to the target computer.
  2. 单独的安装程序:创建一个单独的安装程序包,用于创建应用程序所需的所有目录,文件,注册表项(即MSI,InstallSheild等),然后最终将应用程序复制到目标计算机。

  3. Self installer: Include all required installation steps in a component that is part of your application. Then use this component to check and create required settings each time the main application executable is run. ie Just run the application to install.
  4. 自安装程序:在作为应用程序一部分的组件中包含所有必需的安装步骤。然后在每次运行主应用程序可执行文件时使用此组件检查并创建所需的设置。即只需运行应用程序即可安装。

I've used a few applications that corrupt their settings over time, and most had a separate installer. Therefore the only fix was to to re-install, sometimes with settings and even data being lost (very frustrating).

我使用了一些破坏其设置的应用程序,并且大多数都有单独的安装程序。因此,唯一的解决方法是重新安装,有时设置甚至数据丢失(非常令人沮丧)。

Also during software projects I've worked on, the separate installer approach often dictated spreading application specific knowledge across both the installer package and the actual application. Then, when code/functionality changes were made, both the installer and app needed to be updated. It always felt a bit too brittle and prone to human error.

此外,在我参与的软件项目中,单独的安装程序方法通常要求在安装程序包和实际应用程序中传播应用程序特定的知识。然后,当进行代码/功能更改时,需要更新安装程序和应用程序。它总是感觉有点太脆,容易出现人为错误。

So I'm currently leaning toward the self installer approach because of a simpler more robust installation/setup, ie just run the app. This self installing approach I feel would also lend itself a more robust application.

所以我现在倾向于自安装方法,因为更简单,更强大的安装/设置,即只需运行应用程序。我认为这种自安装方法也可以提供更强大的应用程序。

Integration with in application settings (options) would also be much more clean, in many cases the same component could perform both installation and settings management.

与应用程序设置(选项)集成也会更加干净,在许多情况下,同一组件可以执行安装和设置管理。

On the negative, however, performing these extra checks/steps each time the app starts might negatively impact startup times, and OS integration might be a bit more work then using a standard installer.

然而,在否定的情况下,每次应用程序启动时执行这些额外的检查/步骤可能会对启动时间产生负面影响,并且操作系统集成可能会比使用标准安装程序更多一些工作。

So which approach to people recommend and why?

那么人们推荐哪种方法以及为什么?

(I'm most interested in installation of desktop rich client applications at present.)

(我最感兴趣的是目前安装桌面富客户端应用程序。)

4 个解决方案

#1


There are pros and cons to both approaches:

这两种方法都有利有弊:

  • Having an installer is the proper way to install necessary system components, like drivers, libraries, COM components and so on. Since many of these activities need elevated permissions the install may be performed by the administrator, while the application can be used by all users.

    安装程序是安装必要的系统组件的正确方法,如驱动程序,库,COM组件等。由于许多这些活动需要提升权限,因此安装可以由管理员执行,而应用程序可以由所有用户使用。

  • There may actually be requirements for a scriptable installation procedure in corporate environments.

    实际上,企业环境中可能存在脚本化安装过程的要求。

  • Not having an installer opens the way to portable applications. If the program has everything in a directory, then this can simply be copied to a USB stick and be run on any system. This may of course not make sense for your particular kind of app, but that is for you to decide.

    没有安装程序可以打开便携式应用程序。如果程序包含目录中的所有内容,则可以将其简单地复制到USB记忆棒并在任何系统上运行。这当然对您的特定应用程序没有意义,但这是由您决定的。

I'm not sure that the issue about corrupted settings is really important here. If settings are corrupted (why?) - how is the application to know what to do about it? OTOH the installer can of course also be written to not blindly overwrite any old settings. It all depends...

我不确定有关损坏设置的问题在这里非常重要。如果设置已损坏(为什么?) - 应用程序如何知道如何处理? OTOH当然也可以编写安装程序,不要盲目覆盖任何旧设置。这一切都取决于......

Edit: You write in your comment:

编辑:您在评论中写道:

Even portable apps require certain configuration/settings, Isn't it better to have the main app check that settings are valid/exist on each startup, and only prompt the user when needed.

即使是便携式应用程序也需要某些配置/设置,让主应用程序检查每次启动时设置是否有效/存在并且仅在需要时提示用户不是更好。

and again, it really depends on your needs. There are different types of configuration settings or preferences, and you have to decide individually:

而且,这真的取决于你的需求。有不同类型的配置设置或首选项,您必须单独决定:

  • Per-user configuration settings will be missing if the application is run for the first time by the current user. It can be helpful to show a message that it is missing, and how to create it. For example in FlameRobin (a database administration program for Firebird) we have a message that is shown when no registered servers and databases are found on program startup, and how to register them.

    如果当前用户首次运行应用程序,则将缺少每用户配置设置。显示缺少的消息以及如何创建消息会很有帮助。例如,在FlameRobin(Firebird的数据库管理程序)中,当程序启动时没有找到注册的服务器和数据库时,我们会显示一条消息,以及如何注册它们。

  • Per-user settings for UI behaviour will also be missing, but there are default values for them. The user will get the default behaviour of the application, and can later change things in the option dialog. Since it is best to minimize the number of such settings, and since the defaults should be what most users expect or what works best in the general case, there is also no need to bother the user at program startup.

    UI行为的每个用户设置也将丢失,但它们有默认值。用户将获得应用程序的默认行为,稍后可以在选项对话框中更改内容。由于最好最小化这些设置的数量,并且由于默认值应该是大多数用户期望的或者在一般情况下最有效的,因此在程序启动时也没有必要打扰用户。

  • Some configuration may be not per-user, but per-program. This is generally stored in a location where standard users have no write access, so checking for this and prompt the user to enter it is not really helpful. What could be done is to start an external program, asking the standard user for the account with sufficient privileges and its password.

    某些配置可能不是每个用户,而是每个程序。这通常存储在标准用户没有写访问权限的位置,因此检查并提示用户输入它并不是很有用。可以做的是启动一个外部程序,向该标准用户询问该帐户是否具有足够的权限和密码。

#2


Going with a separate installer is the "better" way from my point of view. Making an application self-installing does not only add additional workload to the application itself, it also "works around" any installer system of the underlying operating system (like MSI on windows).

从我的观点来看,使用单独的安装程序是“更好”的方式。使应用程序自行安装不仅会给应用程序本身增加额外的工作负载,还会“解决”底层操作系统的任何安装程序系统(如Windows上的MSI)。

And if the application corrupt its settings over time it's broken and need to be fixed. How should corrupt settings be handled by the self-installer? Just overwrite it with the defaults? Users will get annoyed by that too, so having them to run a separate installer and choosing a "repair" option makes this at least more transparent.

如果应用程序随着时间的推移破坏了它的设置,它就会被破坏并需要修复。如何通过自安装程序处理损坏的设置?只是用默认值覆盖它?用户也会对此感到恼火,因此让他们运行单独的安装程序并选择“修复”选项会使这至少更加透明。

#3


I would recommend a separate installer that can do the following:

我建议使用单独的安装程序,它可以执行以下操作:

  • Install a new installation
  • 安装新安装

  • Repair an existing installation
  • 修复现有安装

  • Remove an existing installation
  • 删除现有安装

The reason I recommend these options is because that is what I have come to expect for installers in Windows environments.

我推荐这些选项的原因是因为这是我在Windows环境中对安装程序的期望。

The reasons I recommend separating installation and application logic into two different applications area:

我建议将安装和应用程序逻辑分成两个不同的应用程序区域的原因:

  • There may be conflicts between dependencies used used by the installer and application.
  • 安装程序和应用程序使用的依赖项之间可能存在冲突。

  • I want to be sure my team don't inadvertently use classes in the dependencies from the installer framework when developing the application.
  • 我想确保我的团队在开发应用程序时不会无意中使用安装程序框架中的依赖项中的类。

#4


Thanks for your feedback. I'm starting to think something along these lines would be a good compromise approach:

感谢您的反馈意见。我开始认为这些方面的东西将是一个很好的折衷方法:

  • Choose the self installer approach by creating an installer component (class library) that is referenced by the main application.
  • 通过创建主应用程序引用的安装程序组件(类库)来选择自安装程序方法。

  • This component is a core part of the application and is responsible for ensuring all configuration/settings exist and are valid.
  • 该组件是应用程序的核心部分,负责确保所有配置/设置都存在且有效。

  • The main app. executable, on each run, asks this component to check existance/validity of settings, and only prompt the user when required. This could be easily done in a user friendly manner by grouping all setting issues and presenting them in a single GUI (avoids a sequence of annoying dialogues).
  • 主应用程序。可执行文件在每次运行时要求此组件检查设置的存在/有效性,并仅在需要时提示用户。通过对所有设置问题进行分组并将它们呈现在单个GUI中(避免一系列恼人的对话),可以以用户友好的方式轻松完成。

  • For OS integration, the installer component (in the case of Windows) ensures an entry is added to the "Add Remove Programs" list for the application, as well as any other OS required conventions.
  • 对于OS集成,安装程序组件(在Windows的情况下)确保将条目添加到应用程序的“添加删除程序”列表,以及任何其他操作系统所需的约定。

  • Within the application the standard options/settings screen is also provided by the installer component. This avoids duplicating settings management code.
  • 在应用程序中,安装程序组件也提供标准选项/设置屏幕。这可以避免重复设置管理代码。

I've asked this question because I've met many non-technical users who ask why they cannot simply copy an application from one computer to another, they can do this with their data (eg photos, documents etc). It's an extremely valid question, in particular for GUI oriented desktop applications.

我问过这个问题,因为我遇到了许多非技术用户,他们问为什么他们不能简单地将应用程序从一台计算机复制到另一台计算机,他们可以用他们的数据(例如照片,文档等)来完成。这是一个非常有效的问题,特别是对于面向GUI的桌面应用程序。

Separate installers are certainly "the way it's been done" on Windows for many years. For drivers/system components, obviously they are often a necessity. But for desktop GUI style applications I don't believe they are the best in terms of simplicity and realiability for the user/customer.

多年来,单独的安装程序肯定是“在Windows上完成的方式”。对于驱动程序/系统组件,显然它们通常是必需的。但对于桌面GUI风格的应用程序,我认为它们在用户/客户的简单性和可靠性方面并不是最好的。

#1


There are pros and cons to both approaches:

这两种方法都有利有弊:

  • Having an installer is the proper way to install necessary system components, like drivers, libraries, COM components and so on. Since many of these activities need elevated permissions the install may be performed by the administrator, while the application can be used by all users.

    安装程序是安装必要的系统组件的正确方法,如驱动程序,库,COM组件等。由于许多这些活动需要提升权限,因此安装可以由管理员执行,而应用程序可以由所有用户使用。

  • There may actually be requirements for a scriptable installation procedure in corporate environments.

    实际上,企业环境中可能存在脚本化安装过程的要求。

  • Not having an installer opens the way to portable applications. If the program has everything in a directory, then this can simply be copied to a USB stick and be run on any system. This may of course not make sense for your particular kind of app, but that is for you to decide.

    没有安装程序可以打开便携式应用程序。如果程序包含目录中的所有内容,则可以将其简单地复制到USB记忆棒并在任何系统上运行。这当然对您的特定应用程序没有意义,但这是由您决定的。

I'm not sure that the issue about corrupted settings is really important here. If settings are corrupted (why?) - how is the application to know what to do about it? OTOH the installer can of course also be written to not blindly overwrite any old settings. It all depends...

我不确定有关损坏设置的问题在这里非常重要。如果设置已损坏(为什么?) - 应用程序如何知道如何处理? OTOH当然也可以编写安装程序,不要盲目覆盖任何旧设置。这一切都取决于......

Edit: You write in your comment:

编辑:您在评论中写道:

Even portable apps require certain configuration/settings, Isn't it better to have the main app check that settings are valid/exist on each startup, and only prompt the user when needed.

即使是便携式应用程序也需要某些配置/设置,让主应用程序检查每次启动时设置是否有效/存在并且仅在需要时提示用户不是更好。

and again, it really depends on your needs. There are different types of configuration settings or preferences, and you have to decide individually:

而且,这真的取决于你的需求。有不同类型的配置设置或首选项,您必须单独决定:

  • Per-user configuration settings will be missing if the application is run for the first time by the current user. It can be helpful to show a message that it is missing, and how to create it. For example in FlameRobin (a database administration program for Firebird) we have a message that is shown when no registered servers and databases are found on program startup, and how to register them.

    如果当前用户首次运行应用程序,则将缺少每用户配置设置。显示缺少的消息以及如何创建消息会很有帮助。例如,在FlameRobin(Firebird的数据库管理程序)中,当程序启动时没有找到注册的服务器和数据库时,我们会显示一条消息,以及如何注册它们。

  • Per-user settings for UI behaviour will also be missing, but there are default values for them. The user will get the default behaviour of the application, and can later change things in the option dialog. Since it is best to minimize the number of such settings, and since the defaults should be what most users expect or what works best in the general case, there is also no need to bother the user at program startup.

    UI行为的每个用户设置也将丢失,但它们有默认值。用户将获得应用程序的默认行为,稍后可以在选项对话框中更改内容。由于最好最小化这些设置的数量,并且由于默认值应该是大多数用户期望的或者在一般情况下最有效的,因此在程序启动时也没有必要打扰用户。

  • Some configuration may be not per-user, but per-program. This is generally stored in a location where standard users have no write access, so checking for this and prompt the user to enter it is not really helpful. What could be done is to start an external program, asking the standard user for the account with sufficient privileges and its password.

    某些配置可能不是每个用户,而是每个程序。这通常存储在标准用户没有写访问权限的位置,因此检查并提示用户输入它并不是很有用。可以做的是启动一个外部程序,向该标准用户询问该帐户是否具有足够的权限和密码。

#2


Going with a separate installer is the "better" way from my point of view. Making an application self-installing does not only add additional workload to the application itself, it also "works around" any installer system of the underlying operating system (like MSI on windows).

从我的观点来看,使用单独的安装程序是“更好”的方式。使应用程序自行安装不仅会给应用程序本身增加额外的工作负载,还会“解决”底层操作系统的任何安装程序系统(如Windows上的MSI)。

And if the application corrupt its settings over time it's broken and need to be fixed. How should corrupt settings be handled by the self-installer? Just overwrite it with the defaults? Users will get annoyed by that too, so having them to run a separate installer and choosing a "repair" option makes this at least more transparent.

如果应用程序随着时间的推移破坏了它的设置,它就会被破坏并需要修复。如何通过自安装程序处理损坏的设置?只是用默认值覆盖它?用户也会对此感到恼火,因此让他们运行单独的安装程序并选择“修复”选项会使这至少更加透明。

#3


I would recommend a separate installer that can do the following:

我建议使用单独的安装程序,它可以执行以下操作:

  • Install a new installation
  • 安装新安装

  • Repair an existing installation
  • 修复现有安装

  • Remove an existing installation
  • 删除现有安装

The reason I recommend these options is because that is what I have come to expect for installers in Windows environments.

我推荐这些选项的原因是因为这是我在Windows环境中对安装程序的期望。

The reasons I recommend separating installation and application logic into two different applications area:

我建议将安装和应用程序逻辑分成两个不同的应用程序区域的原因:

  • There may be conflicts between dependencies used used by the installer and application.
  • 安装程序和应用程序使用的依赖项之间可能存在冲突。

  • I want to be sure my team don't inadvertently use classes in the dependencies from the installer framework when developing the application.
  • 我想确保我的团队在开发应用程序时不会无意中使用安装程序框架中的依赖项中的类。

#4


Thanks for your feedback. I'm starting to think something along these lines would be a good compromise approach:

感谢您的反馈意见。我开始认为这些方面的东西将是一个很好的折衷方法:

  • Choose the self installer approach by creating an installer component (class library) that is referenced by the main application.
  • 通过创建主应用程序引用的安装程序组件(类库)来选择自安装程序方法。

  • This component is a core part of the application and is responsible for ensuring all configuration/settings exist and are valid.
  • 该组件是应用程序的核心部分,负责确保所有配置/设置都存在且有效。

  • The main app. executable, on each run, asks this component to check existance/validity of settings, and only prompt the user when required. This could be easily done in a user friendly manner by grouping all setting issues and presenting them in a single GUI (avoids a sequence of annoying dialogues).
  • 主应用程序。可执行文件在每次运行时要求此组件检查设置的存在/有效性,并仅在需要时提示用户。通过对所有设置问题进行分组并将它们呈现在单个GUI中(避免一系列恼人的对话),可以以用户友好的方式轻松完成。

  • For OS integration, the installer component (in the case of Windows) ensures an entry is added to the "Add Remove Programs" list for the application, as well as any other OS required conventions.
  • 对于OS集成,安装程序组件(在Windows的情况下)确保将条目添加到应用程序的“添加删除程序”列表,以及任何其他操作系统所需的约定。

  • Within the application the standard options/settings screen is also provided by the installer component. This avoids duplicating settings management code.
  • 在应用程序中,安装程序组件也提供标准选项/设置屏幕。这可以避免重复设置管理代码。

I've asked this question because I've met many non-technical users who ask why they cannot simply copy an application from one computer to another, they can do this with their data (eg photos, documents etc). It's an extremely valid question, in particular for GUI oriented desktop applications.

我问过这个问题,因为我遇到了许多非技术用户,他们问为什么他们不能简单地将应用程序从一台计算机复制到另一台计算机,他们可以用他们的数据(例如照片,文档等)来完成。这是一个非常有效的问题,特别是对于面向GUI的桌面应用程序。

Separate installers are certainly "the way it's been done" on Windows for many years. For drivers/system components, obviously they are often a necessity. But for desktop GUI style applications I don't believe they are the best in terms of simplicity and realiability for the user/customer.

多年来,单独的安装程序肯定是“在Windows上完成的方式”。对于驱动程序/系统组件,显然它们通常是必需的。但对于桌面GUI风格的应用程序,我认为它们在用户/客户的简单性和可靠性方面并不是最好的。