如何更好地利用 MSI 文件
您可能知道,msiexec< /a> 是一个命令行应用程序,可用于安装 MSI 文件。 如您所知,您可以在静默或隐形模式下运行它。
如果安装程序要求用户回答有关要安装哪些部分的具体问题,是否可以通过某种方式在 msiexec 命令行中添加一系列选项来执行此操作?
我认为必须有某种方法来设置 MSI 文件的默认设置才能实现这一点。 MSI 文件是如何制作的? 它们是通过 Microsoft 的工具开发的吗? 它们可以打开和编辑吗?
As you might know, msiexec is a command line application that you can use to install an MSI file. As you might know, you can run it in silent or invisible mode.
If the installer requires the user to answer specific questions about what parts to install, is there some way that I can put in the msiexec command line a series of options to do this?
I figure there must be some sort of way of setting the MSI file's default settings to make this happen. How are MSI files made? Are they developed through tools from Microsoft? Can they be opened and edited?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
配置 MSI 安装
在静默安装 MSI 时,您需要做的是从 msiexec.exe 命令行或通过对原始 MSI 文件应用所谓的转换来配置设置。 这两个选项在下面的单独部分中进行了描述。
如果 MSI 文件设计良好,您将能够从 msiexec.exe 命令行或通过使用转换文件修改原始 MSI 来设置公共属性(它们始终为大写)。 这些操作描述如下。 公共属性最容易在 MSI 文件的“属性表"。 使用您选择的 MSI 工具打开 *.msi 文件 并导航到“属性”表。 您还可以使用一些免费 MSI 工具来生成转换和查看(和编辑)MSI 文件:如何比较两个(或更多)MSI 文件的内容?(指向底部的链接)。
精心设计的 MSI 设置可以通过这些公共属性进行完全配置。 设计不当的 MSI 文件则不然。 设计不当的 MSI 文件最好使用转换文件进行调整(这可以对整个 MSI 文件进行重大更改以在安装时应用)。 设置公共属性只能更改公共属性可配置的内容 - 由设置创建者设计。 转换几乎可以更改整个 MSI 文件中的任何内容。
一般来说,所有企业静默部署都是使用转换来“将 MSI 文件打造成符合企业标准的形状”来完成的。它是一种非常有效的企业部署工具,并且被广泛使用。
几个用于安全保存的链接:
MSI“功能”
MSI 通常是违反直觉的,并且在幕后有些复杂。 然而,过度简化的 MSI 文件包含一个或多个“功能” - 正如您所说,这些功能共同构成“应用程序的位”。 反过来,功能由“组件”组成——它们是整个软件安装的原子单元——但这是一个非常技术性的细节——这个答案是关于 MSI 的用户公开位的——特点。
您通常可以通过交互式运行安装程序来找到这些功能的列表,并导航到自定义安装对话框(并不总是存在)。 此处显示的功能是应用程序的“用户可配置”部分,可以选择排除或包含这些部分(有些是强制性的)。 您还可以通过使用上述功能强大的工具打开 MSI 来找到这些功能(您还可以查看下面第 2 部分中的链接)。
典型功能有:核心或程序、字典、示例、插件 ,拼写检查器,SDK & 开发者工具(用于开发工具)等...某些功能是强制性的(必须安装) - 上面的示例是核心和程序 ,其他是可选的,应用程序启动不需要(如上面的开发工具功能)。 可以使应用程序“按需”安装功能 - 例如,当用户启动拼写检查时进行拼写检查。
根据我的经验,大多数用户都希望安装整个应用程序。如果 Windows Installer 意外弹出并开始安装拼写检查器组件,许多用户会非常恼火。 坦白说非常可以理解。 但是,只有少数用户感兴趣的很少使用的模块化组件可以制作成可选组件 - 特别是如果系统管理员可能不希望在其网络上使用该功能。 对于开发者工具来说,情况确实如此——这些工具不应该对普通用户可用。 它们往往是人们搬起石头砸自己脚所需的全部绳索。
如上所述,自定义 MSI 安装通常有两种方法:(1) 使用 msiexec.exe 自定义命令行,或使用 (2) 转换文件。
1:msiexec.exe 命令行:
控制安装过程中安装的功能的最简单且轻量级的方法是使用
msiexec.exe
指定您的功能选择命令行。 有一系列属性用于功能配置。 但是,在大多数情况下,指定ADDLOCAL
就足够了:上面的命令行指定功能“Program”和“Dictionaries”应该是本地安装(功能名称区分大小写!)。 这通常就足够了,但您也可以以类似的方式使用 REMOVE 属性指定要删除的任何功能。 一个特殊的开关是 ADDLOCAL=ALL ,它将在本地磁盘上安装 MSI 中的所有功能(前提是 MSI 中没有额外的逻辑来覆盖它)。 MSDN 上的 ADDLOCAL 属性。
由公共属性定义的一个非常常见的事情是应用程序的许可证密钥。 以下命令行指定安装功能“程序”和“词典”并应用序列号“1234-1234”:
正如上面的描述所暗示的, 每个设置的可自定义属性列表始终不同。 您可以找到 MSI 文件的属性表中列出的大多数属性,但也可能设置一些属性表中未定义的属性。 在大多数情况下,这与仅从设置 GUI 设置的属性相关(在大多数情况下表示设置设计错误)。 所有属性都应在正确编写的包的属性表中定义。
在供应商的下载页面上查找文档,并向他们的支持人员询问与静默安装或大规模部署相关的任何文档。 做起来很快,如果有标准答案模板,答案也可以很快。 能够控制其部署的公司始终能够提供此服务。 在我看来,理想的方法是使用一页 PDF 来描述不同的部署设置。 坦率地说,如果他们不能提供这一点,就给他们一些热度;-)。
2:转换:
MSI 文件本质上是封装在 COM 结构化存储文件中的 SQL 数据库(文件内的文件系统)。 转换文件是通过安装工具构建的“部分数据库”,例如 Orca (SDK 链接),Installshield 或
Wise、高级安装程序等...(链接到不同工具的说明)。 这些转换可以自定义或覆盖 MSI 中的几乎所有设置或数据库字段 - 包括安装的“应用程序部分”(功能)。 创建转换后,您可以在 msiexec.exe 命令行中将其应用程序指定给 MSI:然后,Windows Installer 将在安装开始之前合并 MSI 和转换。 这是希望完全控制 MSI 安装方式的大型组织使用的方法。 MSDN 上的 TRANSFORMS 属性。
如上所述,该选项允许修改 MSI 中的所有设置。 可以对设计不当的 MSI 文件进行大量修复,以实现可靠的部署。 这是由“应用程序打包程序”完成的。 他们的工作是调整所有设置,使其符合公司标准。 他们可能是最有知识的 MSI 专家之一 - 他们在 MSI 文件中看到很多奇怪的东西。
许多工具可用于创建转换,以下是在比较 MSI 文件的更技术背景下对此类工具的描述。 只需直接跳到底部的免费工具列表:如何比较两个(或多个)MSI 文件的内容?
反模式与 Windows Installer 的企业优势:
Windows Installer 有许多设计怪癖并且可能对开发者来说特别烦人。 诚然,有些问题近乎反模式。
潜在的反模式
1
的问题实现自定义操作(自定义安装逻辑)的高度复杂性可以说是不可避免的,并且编写自定义操作的行为在需要时应该是强大的和有能力的 - 因此是复杂的。 如果技术本身提供了通常用于部署的内容,则很少需要自定义操作。 换句话说,您应该使用内置 MSI 功能,而不是自定义操作(如果可用),或者使用 WiX 或第三方部署软件扩展(如果可用)。
WiX 框架(开源)和商业工具等(Installshield、Advanced Installer 等)已经实现了扩展 Windows Installer 的功能,以处理缺失的功能,例如缺乏 XML 文件的升级机制、共享创建和管理、用户和组的创建、高级 IIS 配置、COM+ 安装、更改 ACL 权限、设置防火墙规则、持久安装属性等... 应该有实施自己的自定义操作的需求越来越少。 如果可以的话,始终使用数以千计的其他用户已经测试的功能(甚至数百万用户 - 这些扩展名是由可用的最佳部署专家编写的 - 您认为您可以自己做得更好吗?)。
Windows安装程序的公司优势(非常重要)
需要特定的心态来接近Windows安装程序。 但是,它提供了许多至关重要的公司福利几乎完全缺乏以前的安装技术。 使用MSI文件 建议阅读。 特别是对于那些认为Windows Installer的人比价值更大的麻烦。
简而言之,总结链接的文章, MSI比以前的部署技术的核心公司益处是(在我看来):
这只是樱桃选择最重要的(经过多年的公司部署之后)。 在所有老实说中,这些功能在世界上(对于企业部署而言)都会有所不同,并且尽管它的所有缺陷 ,但MSI确实可以使用MSI。
Windows Installer的暮光之日安装
人员登上了暮光之城,我们只能希望未来的部署技术将保留这些伟大的公司部署福利,并以使每个人的方式和开发人员的方式处理上述的反模式。特别的。
部署是发展的关键部分。 未能成功为潜在的最终用户成功安装您的出色软件可能是整体软件开发中最昂贵的错误。,如果用户从未看到您的软件完全功能齐全,您该如何成功?
必须更好地处理Windows Installer的复杂性(减少),其关键优势必须在接下来的任何范式中正确保留。
一个相当不错的很好: Windows安装程序的摘要。
云平台
所有这一切都有 ; 随着一般计算转移到云平台,部署世界可能会以不可预测的方式改变。 但是,正如著名的俗话说:变化越多,它们保持不变。 部署需要处理将在未来几十年中使用的所有传统技术。 这是有关为什么部署似乎变得更加复杂而又不太复杂的一篇文章 - 尽管有所有营销: 程序安装的好处和真正目的是什么? 。
看到部署的未来将是什么 - 在未来的几年中将是什么。 也许我们会看到家庭计算机的简化部署,而公司部署会比以往任何时候都更加复杂? 将来,大多数部署可能是数据库部署任务,而不是文件和文件夹部署任务。 到目前为止,由于数据库脚本,用户和组创建,共享设置和ACL许可,绩效计数器,防火墙规则更新,广告查询和更新,com+和消息队列配置,服务安装等... - 整个九码。
Configuring MSI Installations
When it comes to installing an MSI silently, what you need to do is to configure the setup either from the msiexec.exe command line, or by applying what is referred to as a transform to the original MSI file. Both these options are described below in separate sections.
If the MSI file is well-designed you will be able to set PUBLIC PROPERTIES (they are always UPPERCASE) from the msiexec.exe command line or by using a transform file to modify the original MSI. These operations are described below. Public properties are easiest to find in the MSI file's "Property table". Use the MSI tool of your choice to open the *.msi file and navigate to the Property table. There are also some free MSI tools you can use to generate transforms and view (and edit) MSI files: How can I compare the content of two (or more) MSI files? (links towards bottom).
Well-designed MSI setups are fully configurable via these public properties. Badly designed MSI files are not. Badly designed MSI files are best to tweak using transform files (which can make substantial changes to the whole MSI file to apply at install time). Setting public properties can only change whatever is configurable by public properties - as designed by the setup creator. Transforms can change almost anything in the whole MSI file.
In general, all corporate, silent deployment is done using transforms to "beat MSI files into shape" for the corporate standard. It is a very effective tool for corporate deployment and is extensively used.
A couple of links for safe-keeping:
MSI "Features"
MSI is often counterintuitive and somewhat complicated under the hood. However, to over-simplify an MSI file contains one or more "Features" - and these features collectively constitute the "bits of the application" as you put it. Features, in turn, consist of "Components" - which are the atomic units of installation for the whole software - but this is a very technical detail - this answer is about the user-exposed bits of MSI - the features.
You can generally find a list of these features by running the setup interactively, and navigate to the customize install dialog (not always present). Features that show up here are the "user configurable" parts of the application that can be chosen for exclusion or inclusion (some are mandatory). You can also find these features by opening an MSI with a capable tool as mentioned above (you can also see links in section 2 below).
Typical features are: Core or Program, Dictionaries, Samples, Plug-Ins, Spell Checker, SDK & Developer Tools (for dev tools), etc... Some features are mandatory (must be installed) - examples above would be Core and Program, others are optional and are not needed for the application to launch (like the dev tools features above). It is possible to make the application install features "on demand" - for example spell checkers when the user initiates a spell check.
In my experience most users want the whole application installed. Many users are very annoyed if Windows Installer pops up unexpectedly and starts installing spell checker components. Frankly very understandable. However, rarely used modular components interesting only to a few users could be made into optional components - especially if system administrators may not want the feature available on their network. This is certainly the case for developer tools - these should not be available to regular users. They tend to be all the rope people need to shoot themselves in the foot.
As mentioned above, there are generally two ways to customize an MSI installation: (1) using msiexec.exe custom command lines, or using (2) transform files.
1: msiexec.exe command line:
The simplest and light-weight way of controlling what features are installed during an installation, is to specify your feature selection using the
msiexec.exe
command line. There is a whole family of properties used for feature configuration. But, in most cases it is sufficient to specifyADDLOCAL
:The above command line specifies that the features "Program" and "Dictionaries" should be installed locally (feature names are cases-sensitive!). This is generally enough, but you can also specify any features that you want to remove using the REMOVE property in a similar fashion. A special switch is
ADDLOCAL=ALL
which will install all features in the MSI on the local disk (provided there is not additional logic in the MSI to override this). ADDLOCAL property on MSDN.A very common thing to define by public properties is the license key for the application. The following command line specifies to install the features "Program" and "Dictionaries" and to apply the serial key "1234-1234":
As is implied in the description above, the list of customizable properties for each setup is always different. You can find most properties listed in the MSI file's Property table, but it is also possible that some properties can be set that are not defined in the Property table. In most cases this relates to properties being set only from the setup GUI (indicates a setup design error in most cases). All properties should be defined in the property table in a properly authored package.
Look for documentation on the vendor's download page and ask their support for any documents relating to silent installation or large scale deployment. It is quick to do, and answers can be quick if they have standard answer templates. Companies with control of their deployment will always be able to provide this. In my view the ideal way is a one-page PDF which describes different deployment settings. Frankly, give them some heat if they can't provide this ;-).
2: Transforms:
MSI files are essentially SQL-databases wrapped in COM structured storage files (file system within a file). Transform files are "partial databases" constructed via installation tools such as Orca (SDK link), Installshield or
Wise, Advanced Installer, etc... (link to descriptions of the different tools). These transforms can customize or override almost all settings or database fields in an MSI - including what "parts of the application" (features) are installed. After creating a transform you specify its application to the MSI at the msiexec.exe command line:Windows Installer will then merge the MSI and the transform before installation starts. This is the approach used by large organizations who want full control of how the MSI gets installed. TRANSFORMS property on MSDN.
As mentioned above this is the option that allows all settings in an MSI to be modified. Substantial fixes can be applied to badly designed MSI files to allow reliable deployment. This is done by "application packagers". Their job is to tune all setups to work within the corporate standard. They can be among the most knowledgeable MSI specialists around - they see a lot of weird stuff in MSI files.
Many tools can be used to create a transform, here is a description of such tools inside the more technical context of comparing MSI files. Just jump straight to the list of free tools at the bottom: How can I compare the content of two (or more) MSI files?
Anti-Patterns Vs The Corporate Benefits of Windows Installer:
Windows Installer has many design quirks and may be particularly annoying for developers. Admittedly there are some issues that border on anti-patterns.
Potential Anti-Patterns
The issue of high complexity of implementing custom actions (custom installation logic), could be argued to be unavoidable and the act of writing a custom action should be powerful and capable once needed - and hence complicated. Rarely should custom actions be needed if the technology itself offers what is commonly used for deployment. In other words you should use built-in MSI features rather than custom actions if they are available, or WiX or third party deployment software extension when available.
The WiX framework (open source) and commercial tools alike (Installshield, Advanced Installer, etc...) have implemented features to extend Windows Installer to deal with missing features such as the lack of an upgrade mechanism for XML files, share creation and management, creation of users and groups, advanced IIS configuration, COM+ installations, changing ACL permissions, setting firewall rules, persisting installation properties, etc... There should be less and less need to implement your own custom actions. Always use the features that are already tested by thousands of other users if you can (millions of users even - and these extensions have been written by the best deployment experts available - do you think you can do it better on your own?).
The Corporate Benefits of Windows Installer (very significant)
It requires a specific mindset to approach Windows Installer. However, it provides a number of crucial corporate benefits that were almost entirely lacking in previous installation technologies. The corporate benefits of using MSI files is recommended reading. Particularly for those who think Windows Installer is more trouble than it is worth.
To summarize the linked article in brief, the core corporate benefits of MSI over previous deployment technologies are (in my opinion):
That's just to cherry pick the most important ones (after many years doing corporate deployment). In all honesty these features make all the difference in the world (for corporate deployment) and truly makes MSI great to use despite all its flaws.
The Twilight Years Of Windows Installer
As Windows Installer hits its twilight years, we can only hope that the deployment technologies of the future will preserve these great corporate deployment benefits and deal with the mentioned anti-patterns in a way that benefits everyone, and developers in particular.
Deployment is a crucial part of development. Failing to get your great software successfully installed for your potential end users may be the most expensive mistake to make in software development overall. How can you succeed if the user never sees your software fully functional?
Windows Installer's complexity must be handled better (reduced), and its crucial benefits must be preserved properly in whatever paradigm comes next.
A reasonably good: summary of Windows Installer.
Cloud Platforms
With all this said; as computing in general moves to cloud-platforms, the world of deployment is likely to change considerable in unpredictable ways. However, as the famous saying goes: the more things change, the more they stay the same. Deployment needs to deal with all legacy technology that will be in use in companies for decades to come. Here is a piece on why deployment seems to get more complicated and not less complicated - despite all the marketing: What is the benefit and real purpose of program installation?.
It will be interesting to see what the future of deployment will be - in the years to come. Perhaps we will see simplified deployment for home computers, and corporate deployment will become more complicated than ever? In the future most deployment will probably be a database deployment task more than a file and folder deployment task. Server deployment can be extremely complicated as of now with database scripts, user and group creation, share setup and ACL permissioning, performance counters, firewall rules updates, AD queries and updates, COM+ and message queue configuration, service installation, etc... - the whole nine yards.
将带有 MSI 的用户界面视为可选。 这意味着不需要任何答案,因为开发人员已经设置了合理的默认值,这样就不会出现问题。
我们以 MSI 格式向企业客户分发软件,我还为他们提供有关 Orca 基础知识的文档(orca.msi 随 Windows Installer SDK)以及如何自定义我们在<中列出的某些字段其安装的 code>Property 表。 例如序列号、注册详细信息和一些其他设置。
为了回答有关 msiexec 命令行选项 的原始问题,只需运行
MSIEXEC /?
在命令行上设置属性,您将使用类似的内容Think of the user interface with MSI as optional. This means no answers should be required as the developer has sensible defaults in place so that things don't break.
We distribute our software in MSI format to corporate customers, I also provide them with documentation on the basics of Orca (orca.msi is distributed with the Windows Installer SDK) and how to customize certain fields we have listed in the
Property
table for their installation. Such as serial number, registration details and a few other settings.In response to the original question about msiexec command line options just run
MSIEXEC /?
to set properties on the command line you would use something like如何配置静默 MSI 安装
可以通过设置安装程序使用的属性在命令行上配置 MSI 安装。 有预定义的 Windows Installer 属性,例如 ALLUSERS 属性。 此属性定义是否在当前用户或计算机的上下文中完成安装。
有关可用属性的信息可以从安装日志中获取,该安装日志可以使用 msiexec 的 /l 选项创建
如何创建 MSI 文件
创建 MSI 文件的方法有多种。 MSI 文件基本上是一个数据库,由各种表组成,其中包含所有必要的设置信息和安装对话框。
Microsoft 提供了一个简单的工具调用 Orca,它使您能够编辑现有的 MSI 文件并允许您查找可以设置哪些属性来配置安装。 理论上,也可以使用此工具创建新的 MSI 文件,但这是一种非常麻烦的方法。
如果您正在寻找免费的开源解决方案,我建议您查看 WiX 工具集在 SourceForge 或 Nullsoft 上可用。 所有安装信息均通过 XML 文件完成,然后将其转换为 MSI 安装程序。 WiX 很稳定(尽管仍标记为测试版)并且可以在生产中使用。 实际上,它将集成在即将推出的 Visual Studio 2010 版本中。
当然,也有可用的商业解决方案,InstallShield 是市场领导者(也是价格领导者),而 Visual Studio 可能是最广泛使用的工具。
How to configure silent MSI setup
An MSI installation can be configured on the command line by setting the properties that the installer uses. There are pre-defined Windows Installer properties such as the ALLUSERS property. This property defines whether an installation will be done in the context of the current user or the machine.
Information on the available properties can e.g. be obtained from an install log which can be created using msiexec's /l option
How to create MSI files
There are many ways to create MSI files. An MSI file is basically a database consisting of various tables containing all necessary setup information and installation dialogs.
Microsoft offers a simple tool call Orca which enables you to edit existing MSI files and allows you to find out which properties can be set to configure an installation. Theoretically it is also possible to create new MSI files using this tool but it is a very cumbersome way to go.
If you are looking for a free and open source solution I would recommend you to have a look at the WiX toolset available on SourceForge or the Nullsoft . All setup information is done via XML files which are then converted into an MSI installer. WiX is stable (although still tagged beta) and can be used in production. Actually it will be integrated in the upcoming version of Visual Studio 2010.
Of course there are also commercial solutions available, InstallShield being the market leader (also being the price leader) and Visual Studio probably being the most wide-spread tool.