INSTALLLEVEL不安装function

我有两个function:

<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; } 

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

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

此外, 详细的安装日志大大有助于确定是否以及为什么没有安装功能或组件。 只需在日志中搜索InstallValidate,然后检查功能和组件状态并安装操作。

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

参照这个链接 ,从UI中更改INSTALLLEVEL已经太晚了,因为在CostFinalize标准操作下考虑了INSTALLLEVEL,并且在我有时间让用户选择其功能并调用之前执行CostFinalize标准操作我的行动。 Cosmin,我认为InstallValidate之前的INSTALLLEVEL并不重要,在这种情况下,它在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; } }