【问题标题】:INSTALLLEVEL Doesn't Install a FeatureINSTALLLEVEL 不安装功能
【发布时间】:2011-12-09 20:48:10
【问题描述】:

我有两个特点:

    <Feature Id='BaseProductFeatures' Title='Feature 1' Level='1'>
        <ComponentRef Id='WebAppVDirComponent'/>
        <ComponentRef Id='someVDirComponent'/>
        <ComponentRef Id='anotherWCFVDirComponent'/>
        <ComponentGroupRef Id='group_IMPORTFOLDERFILES'/>
        <ComponentGroupRef Id='group_WINSERVERFILES'/>
    </Feature>

    <Feature Id='SMSGWFeature' Title='Feature 2' Level='2'>
        <ComponentGroupRef Id='group_SMSGWWEBAPPFILES'/>
    </Feature>

在安装之前,我使用自定义操作将 INSTALLLEVEL 更改为 2:

    [CustomAction]
    public static ActionResult ChangeInstallLevel(Session session) {
        session["INSTALLLEVEL"] = "2";
        return ActionResult.Success;
    }

值已设置,但未安装功能 2 (SMSGWFeature)。这是为什么?我没有看到 ComponentGroupRef 中的任何组件 group_SMSGWWEBAPPFILES 安装在我希望看到它们的目录中。但是如果我将功能级别 2 (SMSGWFeature) 设置为 1,安装程序将工作。

【问题讨论】:

    标签: c# windows installation wix windows-installer


    【解决方案1】:

    确保您的自定义操作在InstallExecuteSequence 中的InstallValidate 操作之前执行。在 InstallValidate 之后设置 INSTALLLEVEL 不会影响任何事情。

    此外,verbose installation log 可以极大地帮助确定是否以及为什么未安装某个功能或组件。只需在日志中搜索 InstallValidate 并检查功能和组件状态以及安装操作。

    【讨论】:

    【解决方案2】:

    好吧,日志文件什么也没说,我在 InstallValidate 之前设置了 INSTALLLEVEL(我在安装之前在用户界面中设置了它)。至于开销,这一切都在这台慢速机器上发生得很快,但又是我在 UI 中使用的自定义操作,点击下一个按钮。但我发现了问题所在以及如何解决它。

    参考this link,从 UI 更改 INSTALLLEVEL 为时已晚,因为在 CostFinalize 标准操作下考虑了 INSTALLLEVEL,并且在我有时间让用户选择之前执行了 CostFinalize 标准操作他的特点和召唤我的行动。 Cosmin,我认为 INSTALLLEVEL 在 InstallValidate 之前并不重要,它似乎要早得多,在这种情况下,它在 CostFinalize 之前被考虑在内。

    我必须做的如下......

    我更改了我的第二个功能以允许它不存在:

    <Feature Id='BaseProductFeatures' Title='Feature 1' Level='1'>
        <ComponentRef Id='WebAppVDirComponent'/>
        <ComponentRef Id='someVDirComponent'/>
        <ComponentRef Id='anotherWCFVDirComponent'/>
        <ComponentGroupRef Id='group_IMPORTFOLDERFILES'/>
        <ComponentGroupRef Id='group_WINSERVERFILES'/>
    </Feature>
    
    <Feature Id='SMSGWFeature' Title='Feature 2' Level='2' Absent='allow'>
        <ComponentGroupRef Id='group_SMSGWWEBAPPFILES'/>
    </Feature>
    

    我将自定义操作更改为启用或禁用该功能:

    foreach (FeatureInfo aFeature in session.Features) {
        if (session["INSTALLSMSGATEWAYSERVICE"] == "" && aFeature.Name == "SMSGWFeature") {
            aFeature.RequestState = Microsoft.Deployment.WindowsInstaller.InstallState.Absent;
        }
        else if (session["INSTALLSMSGATEWAYSERVICE"] == "1" && aFeature.Name == "SMSGWFeature") {
            aFeature.RequestState = Microsoft.Deployment.WindowsInstaller.InstallState.Local;
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-06
      • 1970-01-01
      • 2021-06-06
      • 2013-10-25
      • 2014-09-15
      • 1970-01-01
      相关资源
      最近更新 更多