我的安装程序我想根据FeatureTree中选择的功能运行一些脚本。但似乎安装程序执行我添加的所有脚本。
<Feature Id="FeatureProduct" Title="App Setup" Level="1" ConfigurableDirectory="INSTALLFOLDER">
<ComponentGroupRef Id="ComponentsProduct" />
<ComponentRef Id="ComponentMenuStart" />
<ComponentRef Id="ComponentDesktopFolder"/>
<ComponentRef Id='SqlComponent.DatabaseSchemeCreator' />
<Feature Id='NE051' Title='Module1' Description='Module 1' Level='1'>
<ComponentRef Id='ComponentModules.Module1' />
<ComponentGroupRef Id='ComponentGroupModul1' />
<ComponentRef Id='SqlComponent.DatabaseModule1' />
</Feature>
<Feature Id='NE041' Title='module2' Description='Module 2' Level='1'>
<ComponentRef Id='ComponentModules.Module2' />
<ComponentGroupRef Id='ComponentGroupModul2' />
</Feature>
</Feature>
<Fragment>
<DirectoryRef Id="TARGETDIR">
<Component Id="SqlComponent.DatabaseSchemeCreator" Guid="2E7CB14E-7190-4C35-A83F-9B1A5C7A2923">
<Condition><![CDATA[AUTO_CONFIGURE_DB = 1]]></Condition>
<sql:SqlDatabase Id='SqlComponent.DatabaseSchemeCreator' Database='[PROP_SQL_DATABASE_NAME]' Server='[PROP_SQL_SERVER_NAME]'
CreateOnInstall='yes' ContinueOnError='no'>
<sql:SqlScript Id='SqlComponent.DatabaseSchemeCreator' BinaryKey='CreateTablesScript' ExecuteOnInstall='yes' />
</sql:SqlDatabase>
</Component>
</DirectoryRef>
<Fragment>
<DirectoryRef Id="TARGETDIR">
<Component Id="SqlComponent.DatabaseModule1" Guid="B7E392C5-3A1E-4F73-9B86-54394E93330B">
<Condition><![CDATA[AUTO_CONFIGURE_DB = 1]]></Condition>
<sql:SqlDatabase Id='SqlComponent.DatabaseModule1' Database='[PROP_SQL_DATABASE_NAME]' Server='[PROP_SQL_SERVER_NAME]'
CreateOnInstall='yes' ContinueOnError='no'>
<sql:SqlScript Id='SqlComponent.DatabaseModule1' BinaryKey='Module1Script' ExecuteOnInstall='yes' />
</sql:SqlDatabase>
</Component>
</DirectoryRef>
每次我没有在FeatureTree中标记模块1来安装Wix时执行模块1的脚本。组件中的条件运行良好。您有任何想法如何防止这种情况吗?
答案 0 :(得分:0)
据我所知,您没有为组件使用任何功能状态(或AUTO_CONFIGURE_DB
- 属性来自哪里?)。
如果我理解正确,您只希望在相关功能已设置为安装时执行这些脚本。根据{{3}},您可以在条件中使用&feature-action
:
For example, the conditional expression "&MyFeature=3" evaluates to True only if MyFeature is changing from its current state to the state of being installed on the local computer, INSTALLSTATE_LOCAL.
在您的情况下,这可能会转换为以下内容,例如:仅当已选择要在本地安装功能NE051
时才执行脚本:
<Fragment>
<DirectoryRef Id="TARGETDIR">
<Component Id="SqlComponent.DatabaseSchemeCreator" Guid="2E7CB14E-7190-4C35-A83F-9B1A5C7A2923">
<Condition><![CDATA[&NE051=3]]></Condition>
<sql:SqlDatabase Id='SqlComponent.DatabaseSchemeCreator' Database='[PROP_SQL_DATABASE_NAME]' Server='[PROP_SQL_SERVER_NAME]' CreateOnInstall='yes' ContinueOnError='no'>
<sql:SqlScript Id='SqlComponent.DatabaseSchemeCreator' BinaryKey='CreateTablesScript' ExecuteOnInstall='yes' />
</sql:SqlDatabase>
</Component>
</DirectoryRef>
</Fragment>