为什么在使用MSI时将文件部署限制在用户配置文件或HKCU中是一个好主意? [英] Why is it a good idea to limit deployment of files to the user-profile or HKCU when using MSI?

查看:156
本文介绍了为什么在使用MSI时将文件部署限制在用户配置文件或HKCU中是一个好主意?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么最好将文件从我的MSI或安装文件限制到用户配置文件或HKCU部署?


部署是大多数开发的关键部分.请给这个内容一个机会.我坚信,可以通过在应用程序设计中进行很小的更改来显着提高软件质量,从而使部署更合理,更可靠-这就是答案"的全部内容-软件开发. >


这是一个Q/A风格的问题,它与答案变得太长了:解决方案

如上所述本节与范围更广的现有答案分开: 部署每用户文件和设置的问题有些混乱:

  • 您如何引用计数多次安装的组件? (针对计算机上的每个用户)
  • 在卸载时如何处理已安装的数据和设置?
  • 您如何处理要安装的新文件和设置,这些新文件和设置与磁盘和注册表中的新文件和设置不同,并且需要用户进行更改?您确定不会自动覆盖吗?

没有真正明确的答案,但是有几种替代方法可以解决问题".我的首选是2& 3,因为我认为Windows安装程序不应该部署,跟踪或尝试进行修改或更糟糕的是,根本不要卸载用户数据和设置-不应干预用户数据:

9.1使用Windows Installer自我修复或类似方法

第一个选项是通过安装程序本身或类似于安装程序的功能来获取正确部署的设置和文件以及HKCU注册表项.有两种主要方法:依靠通常由广告快捷方式触发的Windows Installer"自我修复",或使用

  • 还有另一种方法可以实现这一目标,它称为主动设置允许任何可运行的内容"被执行-对于例如,将文件副本复制到用户配置文件. .

  • 这两个选项均意味着将用户数据和设置一次复制到位-从那时起,它们通常不会被触及,但是在自我修复"的情况下,对于任何实际运行应用程序的卸载(除非安装程序设计为不这样做).

  • 尽管使用自我修复"和活动安装"设置用户数据是使应用程序正常运行的既定"方法,但是使用Windows Installer组件跟踪用户数据似乎是错误的.为什么?因为实际上是用户数据,一旦初始化就不应该干预.

  • 因此,我对整个问题的诚实看法是避免完全部署用户特定的数据或注册表项和值,这就是接下来要介绍的另外两个用户数据部署方法.

  • 9.2 用户数据的应用程序初始化

    第二种方法,也是我发现更干净的一种方法,是更改您的应用程序可执行文件,以便能够基于默认设置以及从每台计算机位置或根据应用程序复制的模板来初始化所有按用户设置和文件.内部默认值(来自源代码),而不是通过设置写入.

    • 在这种情况下,Windows Installer将不会跟踪复制到每个用户的文件或设置.它被视为完全不应受到干扰的用户数据. 这避免了所有干扰,例如在升级和自我修复(以及手动卸载和重新安装)过程中重置或覆盖用户数据.

    • 如果在某些情况下必须对应用程序设置进行修复",则可以通过使应用程序可执行文件在启动时为每个用户更新设置,然后标记注册表完成更新来实现. .

    • 总体而言,结论"是您的设置应为首次启动准备应用程序,而不应设置用户数据和设置环境.如果所有用户配置文件和HKCU设置在启动时丢失,它们都应由应用程序默认设置-这将产生一个更强大的应用程序,也更易于QA人员进行测试.这对于根本不允许运行自我修复的终端服务器尤其重要.在这种情况下,如果您依靠自我修复将用户数据放置到位,则应用程序数据将丢失.

    9.3 云"或用户设置的数据库存储

    要在当今的云环境"中更进一步,我认为这是首选选项.为什么应将您的应用程序限制为文件,注册表项和值?为什么不将所有用户特定的设置存储在解决方案的数据库中?

    • 对所有设置的完全访问,控制和持久性,根本没有任何部署问题.

    • 不过,您确实遇到了新的管理问题,并且必须在开发人员,系统管理员和数据库管理员之间共享.但是,目前云是否不是行业标准?

    • 我们在漫游配置文件,损坏的用户注册表,处理不正确的用户配置文件数据文件等方面已经苦苦挣扎了很长时间.开发人员可以为自己省去很多麻烦,并为自己创建一些新的数据库管理问题,而不是部署问题,然后开始大吼大叫! :-).

    • 数据库中的设置为:

      • 没有遭受双重来源问题"的困扰.有一个实例,并且它是实时更新的.不喜欢在用户配置文件和漫游"中看到的同步问题.

      • 可检查,可管理且可修补

      • 可修改(版本控制-可以还原较早的设置)

    • 作为部署的一部分,您甚至可以通过运行数据库脚本来调整"设置中的所有用户设置,但是,如果您处于公司环境中,则不只是想举起罚单,然后您的数据库管理员是否在适当的事务支持下运行维护脚本,并且回滚更具吸引力?

    • 即使您要交付大型胖客户端供应商应用程序以供一般发行和第三方使用(换句话说,也不是保证拥有后端数据库的量身定制的公司客户端/服务器解决方案) ,应该考虑让用户使用电子邮件或类似内容登录云,然后实时同步设置,从而考虑对用户设置进行云存储.

      • 这样的大型应用程序通常总是需要在计算机和HKCU中缓存"某些设置文件,但是似乎越来越有可能将所有设置保存在用户配置文件区域中的单个临时文件中,这完全是牺牲"文件,如果损坏,甚至可以删除它,然后下载最后保存的设置.

      • 显然,可以使用公司DBO来配置自己的公司范围内的云,从而完全控制所有设置,并且可以强制实施软件操作的强制性策略和限制,而不是自己托管云. .更不用说所有用户设置都可以使用的正确备份了.

    Why is it a good idea to limit deployment of files to the user-profile or HKCU from my MSI or setup file?


    Deployment is a crucial part of most development. Please give this content a chance. It is my firm belief that software quality can be dramatically improved by small changes in application design to make deployment more logical and more reliable - that is what this "answer" is all about - software development.


    This is a Q/A-style question split from an answer that became too long: How do I avoid common design flaws in my WiX / MSI deployment solution?.

    解决方案

    As stated above this section was split from an existing answer with broader scope: How do I avoid common design flaws in my WiX / MSI deployment solution? (an answer intended to help developers make better deployment decisions).


    9. Overuse of per-user file and registry deployment.

    Some applications won't run correctly for all users on a machine, because the user-specific data added during installation isn't correctly added to other user's profiles and registry. In other words the application just works for the user who installed the software. This is obviously a serious design error.

    There are several ways to "fix" this, but the whole issue of deployment of per-user files and settings is somewhat messy for a few fundamental reasons:

    • How do you reference count components installed multiple times? (for each user on the machine)
    • What do you do with the installed data and settings on uninstall?
    • How do you deal with new files and settings to install that differ from the ones that are on disk and in the registry and have user-made changes? Surely you don't overwrite automatically?

    There are no real clear cut answers, but there are several alternative ways to deal with the "problems". My preferred options are 2 & 3 since I don't think Windows installer should deploy, track or attempt to modify or worse yet, uninstall user data and settings at all - it is user data that shouldn't be meddled with:

    9.1 Using Windows Installer Self-Repair or similar

    The first option is to get settings and files and HKCU registry keys deployed properly via the setup itself or setup-like features. There are two major ways to do this: relying on Windows Installer "self-repair" generally triggered by an advertised shortcut, or using Microsoft Active Setup.

    • Self-repair is what happens when you launch a shortcut to start your application, and Windows Installer kicks in and you see a progress bar whilst "something" is being installed. What is typically added are HKCU registry entries and user-profile files.

    • There is also another alternative to achieve this, it is called Active Setup and is also a Microsoft feature. It essentially registers "something runnable" to run once per user on logon. This can be used to set up per-user data. Active Setup allows "anything runnable" to be executed - for example a copy of files to the user-profile. .

    • Both of these options mean that the user data and settings are copied in place once - and from then on they are not generally touched, but in the case of "self-repair" might get uninstalled for any user who actually runs the uninstall of the application (unless the setup is designed not to do so).

    • Although setting up user data with self-repair and Active Setup are "established" methods to get applications running properly, it seems wrong to track user data with Windows Installer components. Why? Because it is really user data that shouldn't be meddled with once initialized.

    • Accordingly my honest take on the whole issue is to try to avoid deploying user specific data or registry keys and values altogether, and this is what is described next as two other user-data deployment methods.

    9.2 Application Initialization of User Data

    The second alternative, and one that I find much cleaner, is to change your application executable to be able to initialize all per-user settings and files based on default setting and templates copied from a per-machine location or based on application internal defaults (from the source code) instead of writing them via your setup.

    • In this scenario Windows Installer will not track the files or settings that are copied to each user. It is treated as user data that should not be interfered with at all. This avoids all interference such as reset or overwritten user data during upgrades and self-repair (and manual uninstall and reinstall).

    • If there are cases where "fixes" must be made to application settings, this can be achieved by having the application executable update the settings for each users on launch, and then tag the registry that the update has been completed.

    • The overall "conclusion" is that your setup should prepare your application for first launch, it should not set up the user data and settings environment. All user-profile files and HKCU settings should be defaulted by the application in case they are missing on launch - this yields a much more robust application that is easier to test for QA personnel as well. This is particularly important for Terminal Servers where self-repair is not allowed to run at all. In such cases the application data will be missing if you rely on self-repair to put user data in place.

    9.3 "Cloud" or Database Storage of User Settings

    To take things a step further in today's "cloud environment" - and this is in my opinion the preferred option. Why should your application be restricted to files and registry keys and values? Why not store all user specific settings in the solution's database?

    • Full access, control and persistence for all settings without any deployment issues at all.

    • You do get new management issues though, and they must be shared between developers, system administrators and database administrators. But isn't the cloud pretty much the industry standard by now?

    • We have been struggling long enough with roaming profiles, corrupted user registry, mishandled user-profile data files, etc.... Developers, save yourself a lot of trouble, and create yourself some new database management issues instead of deployment issues - and start yelling at a whole new bunch of people! :-).

    • Settings in databases are:

      • Not suffering from "dual source problems". There is one instance, and it is updated in real time. Not like the synchronization problems seen with user-profile and "roaming".

      • Inspectable, manageable and patchable

      • Revisable (version control - can revert older settings)

    • You could even "tweak" all the user settings from your setup still by running database scripts as part of deployment, but if you are in a corporate environment - isn't the thought of just raising a ticket and then have your database administrator run the maintenance scripts with proper transaction support and rollback much more appealing?

    • Even if you are delivering a large, fat-client vendor application for general distribution and third party use (in other words not a tailored, corporate client/server solution where you are guaranteed to have a back end database), one should consider cloud storage of user settings by having users log on to a cloud using their email or similar and then synchronize settings in real time.

      • Such large applications generally always need to "cache" some settings files on the computer and in HKCU, but it seems more and more possible to save all settings in a single temporary file in the user profile area which is entirely "sacrificial" and even possible to delete if it is corrupted and then download the last saved settings.

      • Instead of hosting the cloud yourself, it is obviously possible to use company DBOs to configure their own company-wide cloud where they have full control of all settings, and can also enforce mandatory policies and restrictions for your software's operation. Not to mention the proper backup that is possible for all user settings.

    这篇关于为什么在使用MSI时将文件部署限制在用户配置文件或HKCU中是一个好主意?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆