ADDLOCAL =特征1在MSI安装移除其它特征(ADDLOCAL=FEATURE1 in MSI

2019-09-28 16:16发布

我想上的Setup.exe顶部使用维克斯安装SETUP.EXE(2.0)安装FEATURE_NEW之一(1.0)SETUP.EXE / V / QN ADDLOCAL = FEATURE_NEW

它安装FEATURE_NEW,但问题是,它消除了其他功能特征1,特征等。

我想现有的功能应该升级并安装新的FEATURE_NEW,没有附加功能应安装。

所以我的问题是我可以安装/升级产品与先前安装的功能列表“N”加上新加入的功能,即N + NEW_FEATURES。 我正在寻找类似的东西,

SETUP.EXE / V / QN ADDLOCAL = INSTALLED_FEATURES,FEATURE_NEW

Answer 1:

Round 2:

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.

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: 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: 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 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.

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安装包(这实际上是用什么脚本做之前,我将它改编)。

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

第一轮:

特点 :如果你想获取当前已安装的产品的功能安装状态 (功能是用户可选择安装部分: ProgramDictionariesSDKHelpTutorials ,等...),那么通过可能的MSI API 。 我不熟悉的方式通过检索功能安装状态msiexec.exe命令行。

组件 :如果你指的是MSI组件(即分配给用户可选择的功能,但永远不会被用户直接看到安装的原子位),然后我不完全了解你想要达到的目的。 ADDLOCAL是一个功能安装选项属性 ,它会影响功能的安装状态而已,它只是间接影响的组件(那些被分配到功能您参考)。

主要升级 :如果你还没有实施适当的重大升级,并认为这是您所遇到的实际问题,我想知道。 请更多的信息更新你的问题。 一个正确实施的重大升级将安装任何新的组件,删除过时的,并且还安装已添加任何新功能。 之前我写的任何详细信息,请澄清你的问题。

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



Answer 2:

如果你正在做一个ADDLOCAL就会明确地列出将要安装的功能 - 已安装的功能是您指定的内容。 它不是增量,并不意味着“还安装这些功能。” 例如,它关断功能的条件。 如果你想与您可以使用MsiEumFeatures引导程序的重大升级过程中增加新的功能()获取安装的功能列表,向其中添加新的。 另一种方法是使用自定义操作来解析ADDLOCAL串,MigrateFeatureStates后测序,并添加新的列表。



文章来源: ADDLOCAL=FEATURE1 in MSI installer removes other FEATURES