本文介绍了MSI 安装程序中的 ADDLOCAL=FEATURE1 删除了其他功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 setup.exe(1.0) 之上使用 wix installer setup.exe(2.0) 安装 FEATURE_NEW 之一setup.exe/v/qn ADDLOCAL=FEATURE_NEW

I am trying install one of FEATURE_NEW using wix installer setup.exe(2.0) on top of setup.exe(1.0)setup.exe /v /qn ADDLOCAL=FEATURE_NEW

它安装 FEATURE_NEW,但问题是,它删除了其他功能 FEATURE1、FEATURE2 等.

It installs FEATURE_NEW, but issue is, it removes other features FEATURE1,FEATURE2 etc.

我希望现有功能应该升级并安装新的 FEATURE_NEW,不应该安装额外的 FEATURES.

I want existing feature should upgrade and new FEATURE_NEW installed, no additional FEATURES should be installed.

所以我的问题是我可以使用以前安装的功能列表N"加上新添加的功能(即 N + NEW_FEATURES)来安装/升级产品.我正在搜索类似的东西,

So my question is Can I Install/upgrade product with previously installed feature list 'N' plus newly added feature i.e. N + NEW_FEATURES.I am searching something like,

setup.exe/v/qn ADDLOCAL=INSTALLED_FEATURES,FEATURE_NEW

推荐答案

第二轮:

MigrateFeatureStates:我看到您更新了您的问题.看起来您正在处理功能.我假设您正在使用从版本 1 到版本 2 的重大升级?首先是标准的 MSI 操作 MigrateFeatureStates 将尝试保留"主要升级的功能安装状态 - 如果主要升级在 升级表(属性栏),随便提一下.

MigrateFeatureStates: I see you have updated your question. It does look like you are dealing with features. I assume you are using a major upgrade from version 1 to version 2? First of all the standard MSI action MigrateFeatureStates will try to "preserve" the feature installation state for major upgrades - if the major upgrade is configured to do so in the Upgrade table (attributes column), just to mention it.

功能属性:换句话说,如果您设置任何功能属性(ADDLOCAL, ADDSOURCE, REMOVE, ADVERTISE 等...),那么你的新版本应该继承你的第一个版本的功能结构,并且关键是自动安装任何新功能(前提是它们设置为默认安装).

Feature Properties: In other words, if you do not set any feature properties (ADDLOCAL, ADDSOURCE, REMOVE, ADVERTISE, etc...), then your new version should inherit the feature structure of your first version and crucially install any new features automagically (provided they are set to install by default).

MSI API:基于此,我不确定您特定添加的功能是否必要,但如果您的功能不需要 设置为默认安装.如前所述,我不知道通过命令行检索当前功能状态的方法(可能有),但您可以使用 MSI API 然后通过 MSI API 或命令行(或其他方式)调用新安装.

MSI API: Based on this, I am not sure your specific addition of a feature is necessary, but it might be if your feature is not set to install by default. As stated I am not aware of a way to retrieve the current feature state via the command line (there could be one), but you can use the MSI API and then invoke the new install either via MSI API or the command line (or some other way).

Feature Manipulation:我有一个过时的 VBScript,我可以快速适应生成 msiexec.exe 用于特征状态操作的命令行,但在此之前谈到这一点,应该提到的是,您可以使用 MSI 包中的多种机制来控制功能选择:如何根据自定义操作中设置的属性安装功能? 本质上你可以使用自定义操作随意操纵特征选择.您可以详细检查系统以确定应该安装和不安装哪些功能.您还可以使用功能条件来影响功能选择,而无需一行代码(无自定义操作).请参阅上面的链接答案(推荐).还有一个关于MSI 功能"的部分.在这个试图解释它的答案中:Wix 安装程序:在命令行执行 MSIEXEC 管理员安装时设置组件条件属性

Feature Manipulation: I had a dated VBScript I could quickly adapt to generate msiexec.exe command lines for feature state manipulation, but before going into that it should be mentioned that you can use a number of mechanisms within your MSI package to control feature selection: How to install feature based on the property set in custom action? In essence you can use a custom action to manipulate feature selection at will. You can inspect the system in detail to determine what features should be installed and not. You can also use feature conditions to affect feature selection without a single line of code (no custom action). See the linked answer just above (recommended). There is also a section on "MSI Features" in this answer which tries to explain it: Wix Installer : Setting component condition property when doing a MSIEXEC admin install at command line

GUI 功能操作:我还想补充一点,如果您的 GUI 包括自定义对话框屏幕,您可以明显地更改 MSI GUI 中的功能状态,您可以在其中看到即将安装在系统上的功能.

GUI Feature Manipulation: I also want to add that you can obviously change the feature state in the MSI GUI if your GUI includes the Custom dialog screen where you can see the features about to be installed on the system.

总结:总而言之,您可以通过功能条件自定义操作从您的 MSI 中操作功能- 您还可以让用户在 GUI 中交互式和手动更改功能选择.如果这还不够,您可以使用 MSI API 检索已安装 MSI 的功能状态,如下面的 VBScript 所示.脚本生成的是一个命令行片段,它将复制已安装的功能状态,以及您在脚本中指定位置所做的任何添加.您需要输入要获取功能状态的 MSI 的产品代码:如何找到已安装的 MSI 设置的产品 G​​UID?(只需从您的 MSI 的属性表中获取它或来自您的 WiX 来源 - 该链接仅供参考).该脚本默认获取可能出现在您的机器上的常见运行时包的功能状态.

Summary: So in summary you can manipulate features by feature conditions and custom actions from within your MSI - and you can also have the user change the feature selection interactively and manually in the GUI. If that is not enough you can retrieve the feature state for an installed MSI using the MSI API as shown in the VBScript below. What the script produces is a command line snippet which will replicate the installed feature state, with any additions you make in the designated place in the script. You need to input the product code for the MSI you want to get the feature state for: How can I find the product GUID of an installed MSI setup? (just get it from the property table of your MSI or from your WiX source - that link is just for reference). The script defaults to get the feature state for a common runtime package likely to be present on your box.

我想这会产生一些现实世界的选择:

I guess this yields a few real-world options:

  1. 依靠 MigrateFeatureStates 在版本 2 中添加任何新功能.新功能必须设置为默认安装.
  2. 通过自定义操作或功能条件设置功能属性.
  3. 使用 MSI API 检索当前安装的功能状态,并通过 msiexec.exe 使用自定义命令行设置功能属性安装新版本.
  4. 让用户在 GUI 中以交互方式添加他们需要的功能.
  5. 无论我忘记了什么.

很容易扩展此脚本以报告所有已安装 MSI 包的所有功能状态(实际上,在我对其进行修改之前,该脚本曾经执行此操作).

It is easy to extend this script to report all feature states for all installed MSI packages (which is in fact what the script used to do before I adapted it).

这是 github.com 上的以下脚本


On Error Resume Next

Public cmdline

' Sample Product Codes:
  ' Microsoft Visual C++ 2008 Redistributable - x86 9.0.30729.17: {9A25302D-30C0-39D9-BD6F-21E6EC160475}

productcode = InputBox("ProductCode for your MSI:", "ProductCode:","{9A25302D-30C0-39D9-BD6F-21E6EC160475}")
If productcode = vbCancel Or Trim(productcode) = "" Then
   WScript.Quit(0)
End If

' Arrays of current feature states
ReDim ADDLOCAL(-1), ADDSOURCE(-1), ADVERTISE(-1), REMOVE(-1)

Set installer = CreateObject("WindowsInstaller.Installer")
Set productfeatures = installer.Features(productcode)
If (Err.number <> 0) Then
   MsgBox "Failed to open MSI package. Invalid product code?", vbCritical, "Fatal error. Aborting:"
   WScript.Quit(2)
End If

' Spin over all product features detecting installation states
For Each feature In productfeatures

    featurestate = installer.FeatureState(productcode, feature)
   
    ' Using crazy VBScript arrays
    Select Case featurestate
       Case 1 ReDim Preserve ADVERTISE(UBound(ADVERTISE) + 1) : ADVERTISE(UBound(ADVERTISE)) = feature
       Case 2 ReDim Preserve REMOVE(UBound(REMOVE) + 1) : REMOVE(UBound(REMOVE)) = feature
       Case 3 ReDim Preserve ADDLOCAL(UBound(ADDLOCAL) + 1) : ADDLOCAL(UBound(ADDLOCAL)) = feature
       Case 4 ReDim Preserve ADDSOURCE(UBound(ADDSOURCE) + 1) : ADDSOURCE(UBound(ADDSOURCE)) = feature
       Case Else ' Errorstate MsgBox "Error for feature: " + feature
    End Select
    
Next

' Now add whatever feature you need to ADDLOCAL, here is just a sample:
ReDim Preserve ADDLOCAL(UBound(ADDLOCAL) + 1) : ADDLOCAL(UBound(ADDLOCAL)) = "MyNewFeature"

' Flatten arrays
If UBound(ADDLOCAL) > -1 Then cmdline = chr(34) + "ADDLOCAL=" + Join(ADDLOCAL, ",") + chr(34)
If UBound(REMOVE) > -1 Then cmdline = cmdline + + " " + chr(34) + "REMOVE=" + Join(REMOVE, ",") + chr(34)
If UBound(ADVERTISE) > -1 Then cmdline = cmdline + + " " + chr(34) + "ADVERTISE=" + Join(ADVERTISE, ",") + chr(34)
If UBound(ADDSOURCE) > -1 Then cmdline = cmdline + + " " + chr(34) + "ADDSOURCE=" + Join(ADDSOURCE, ",") + chr(34)

' Your current feature installstate translated to msiexec.exe command line parameters
Wscript.Echo cmdline ' MsgBox has 1024 character limit


第一轮:

Features:如果要检索当前安装产品的功能安装状态(功能是用户可选择的安装部分:ProgramDictionariesSDKHelpTutorials 等...),然后这可以通过 MSI API.我不熟悉通过 msiexec.exe 命令行检索功能安装状态的方法.

Features: If you want to retrieve the currently installed product's feature installation state (features are the user-selectable installation parts: Program, Dictionaries, SDK, Help, Tutorials, etc...), then that is possible via the MSI API. I am not familiar with a way to retrieve the feature installation state via the msiexec.exe command line.

组件:如果您指的是 MSI 组件(分配给用户可选功能的安装程序的原子位,但用户永远不会直接看到)),那么我不完全了解您要实现的目标.ADDLOCAL功能安装选项属性之一,它只影响功能安装状态,它只会间接影响组件(那些分配给您所指的功能的组件).

Components: If you are referring to MSI components (the atomic bits of the installer that are assigned to the user selectable features, but are never seen by the user directly), then I do not fully understand what you are trying to achieve. ADDLOCAL is one of the Feature Installation Options Properties, and it affects feature installation state only, it only indirectly affects components (those that are assigned to the feature you refer to).

主要升级:我想知道您是否没有实施适当的主要升级,这才是您遇到的真正问题.请用更多信息更新您的问题.正确实施的主要升级将安装任何新组件、删除过时的组件并安装您添加的任何新功能.在我写更多之前,请澄清你的问题.

Major Upgrade: I am wondering if you have not implemented a proper major upgrade, and that this is the real problem you are experiencing. Please update your question with more information. A properly implemented major upgrade will install any new components, remove obsolete ones and also install any new features you have added. Before I write any more, please clarify your question.

我有一个 VBScript,它将检索您指定的产品(或所有已安装的 MSI 文件)的当前功能状态.如果这确实是您所追求的.

I have a VBScript which will retrieve the current feature state of a product you specify (or for all the installed MSI files for that matter). If that is indeed what you are after.

这篇关于MSI 安装程序中的 ADDLOCAL=FEATURE1 删除了其他功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 07:18