下面是一个示例Wix安装程序,其中包含来自另一个文件的片段。我试图包括功能共同在一个片段多个安装程序和其他地方使用这些片段。
当前不因为我无法按照正确的顺序进行排序特性评估工作。这是可行的,我会怎样做到这一点?
我想的序列是在注释为“序列:1”。等
具体来说,我如何确定嵌入元素和条目之间的顺序?我可以使用行动属性序列的SetProperty条目到一个点,但我不理解如果执行特定RegistrySearch当我能确定或控制。
SampleInstaller.wxs:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="Company" Name="Company">
<Directory Id="INSTALLDIR" Name="ServerDir"/>
</Directory>
</Directory>
</Directory>
<ComponentGroup Id="ServerGroup1" Directory="INSTALLDIR">
<Component Id="SetVal" Guid="*">
<!-- Sequence: 5 -->
<!-- Pre-requisites: 3 -->
<RegistryValue Root="HKLM" Key="[SERVER_REGISTRYHIVE]" Name="MyKey" Type="integer" Value="1" KeyPath="yes" />
</Component>
</ComponentGroup>
<Feature Id="ProductFeature" Title="MyServer" Level="1">
<ComponentGroupRef Id="CompanyDefaultFragment" />
<ComponentGroupRef Id="CompanyInstallerDefaultFragment" />
<ComponentGroupRef Id="CompanyInstallerRegistryEntries"/>
<ComponentGroupRef Id="ServerGroup1" />
</Feature>
<!-- Sequence: 1 -->
<!-- Needed by fragments pulled in from SampleInclude.wxi -->
<Property Id="INSTALLDIR_NAME" Value="MyServer"/>
<!-- Needed by fragments pulled in from SampleInclude.wxi -->
<!-- Sequence: 4 -->
<!-- Pre-requisites: 3 -->
<SetProperty Id="Key1" Action="SetKey1" Value="[SERVER_REGISTRYHIVE]\Key1" Before="AppSearch"/>
</Product>
<?include SampleInclude.wxi ?>
SampleInclude.wxi:
<Include>
<Fragment>
<!-- Common to all installers -->
<ComponentGroup Id="CompanyDefaultFragment"/>
<!-- Sequence: 2 -->
<SetProperty Id="SERVERS_REGISTRYHIVE" Value="Company\Servers" Before="AppSearch"/>
<SetProperty Id="APPLICATIONS_REGISTRYHIVE" Value="Company\Applications" Before="AppSearch"/>
<SetProperty Id="INSTALLERS_REGISTRYHIVE" Value="Company\Installers" Before="AppSearch"/>
<SetProperty Id="MAINAPP_REGHIVE" Value="Company\Applications\MainApp" Before="AppSearch"/>
</Fragment>
<Fragment>
<!-- Specific to current installer -->
<ComponentGroup Id="CompanyInstallerDefaultFragment"/>
<!-- Sequence: 3 -->
<!-- Pre-requisites: 1, 2 -->
<SetProperty Id="INSTALLER_REGISTRYHIVE" Action="SetInstallerRegistryHive" Value="[INSTALLERS_REGISTRYHIVE]\[ProductName]" Before="AppSearch"/>
<!-- SERVER_REGISTRYHIVE is where a server stores its registry entries -->
<!-- Set SERVER_REGISTRYHIVE property if SERVER_REGISTRYHIVE_NAME property is set -->
<SetProperty Id="SERVER_REGISTRYHIVE" Action="SetServerRegistryHive" Value="[SERVERS_REGISTRYHIVE]\[SERVER_REGISTRYHIVE_NAME]" Before="AppSearch" >
<![CDATA[SERVER_REGISTRYHIVE_NAME <> ""]]>
</SetProperty>
<!-- APPLICATION_REGISTRYHIVE is where an application stores its registry entries -->
<!-- Set APPLICATION_REGISTRYHIVE property if APPLICATION_REGISTRYHIVE_NAME property is set -->
<SetProperty Id="APPLICATION_REGISTRYHIVE" Action="SetApplicationRegistryHive" Value="[APPLICATIONS_REGISTRYHIVE]\[APPLICATION_REGISTRYHIVE_NAME]" Before="AppSearch" >
<![CDATA[APPLICATION_REGISTRYHIVE_NAME <> ""]]>
</SetProperty>
<!-- Set INSTALL_DIR_BASE -->
<!-- Set INSTALL_DIR_BASE from the registry if MAINAPP is installed -->
<Property Id="INSTALL_DIR_BASE">
<RegistrySearch Id="BasePath" Root="HKLM" Key="[MAINAPP_REGISTRYHIVE]" Name="BasePath" Type="raw"/>
</Property>
<!-- If MAINAPP is not installed, then default INSTALL_DIR_BASE to [ProgramFiles64Folder]\CompanyName -->
<SetProperty Id="INSTALL_DIR_BASE" Action="SetInstallDirBase" Value="[ProgramFiles64Folder]CompanyName" Before="AppSearch">
<![CDATA[INSTALL_DIR_BASE = ""]]>
</SetProperty>
<!-- Set INSTALLDIR -->
<!-- Get INSTALLDIR from registry. This will return a value when this installer has already been run on this machine -->
<Property Id="INSTALLDIR">
<RegistrySearch Id="InstallDir" Root="HKLM" Key="[INSTALLER_REGISTRYHIVE]" Name="InstallDir" Type="raw" />
</Property>
<!-- If there is no INSTALLDIR in registry, then default it to [INSTALL_DIR_BASE]\[INSTALLDIR_NAME] -->
<SetProperty Id="INSTALLDIR" Action="SetInstallDir" Value="[INSTALL_DIR_BASE]\[INSTALLDIR_NAME]\" Before="AppSearch">
<![CDATA[INSTALLDIR = "" AND INSTALL_DIR_BASE <> "" AND INSTALLDIR_NAME <> ""]]>
</SetProperty>
</Fragment>
<Fragment>
<!-- This fragment writes the standard registry entries for a company installer -->
<ComponentGroup Id="CompanyInstallerRegistryEntries" Directory="TARGETDIR">
<!-- Write the INSTALLDIR to registry so we can use the same location on upgrade/downgrade -->
<Component Id="InstallDirRegComponent" >
<!-- Sequence: 6 -->
<!-- Pre-requisites: 3 -->
<RegistryKey Root="HKLM" Key="[INSTALLER_REGISTRYHIVE]" ForceCreateOnInstall="yes">
<RegistryValue Type="string" Name="InstallDir" Value="[INSTALLDIR]" />
</RegistryKey>
</Component>
</ComponentGroup>
</Fragment>
运行安装程序时出错:
Action 13:42:54: INSTALL.
Action start 13:42:54: INSTALL.
Action 13:42:54: SetAPPLICATIONS_REGISTRYHIVE.
Action start 13:42:54: SetAPPLICATIONS_REGISTRYHIVE.
Action ended 13:42:54: SetAPPLICATIONS_REGISTRYHIVE. Return value 1.
Action 13:42:54: SetInstallDirBase.
Action start 13:42:54: SetInstallDirBase.
Action ended 13:42:54: SetInstallDirBase. Return value 1.
Action 13:42:54: SetInstallerRegistryHive.
Action start 13:42:54: SetInstallerRegistryHive.
Action ended 13:42:54: SetInstallerRegistryHive. Return value 1.
Action 13:42:54: SetINSTALLERS_REGISTRYHIVE.
Action start 13:42:54: SetINSTALLERS_REGISTRYHIVE.
Action ended 13:42:54: SetINSTALLERS_REGISTRYHIVE. Return value 1.
Action 13:42:54: SetKey1.
Action start 13:42:54: SetKey1.
Action ended 13:42:54: SetKey1. Return value 1.
Action 13:42:54: SetMAINAPP_REGHIVE.
Action start 13:42:54: SetMAINAPP_REGHIVE.
Action ended 13:42:54: SetMAINAPP_REGHIVE. Return value 1.
Action 13:42:54: SetSERVERS_REGISTRYHIVE.
Action start 13:42:54: SetSERVERS_REGISTRYHIVE.
Action ended 13:42:54: SetSERVERS_REGISTRYHIVE. Return value 1.
Action 13:42:54: AppSearch. Searching for installed applications
Action start 13:42:54: AppSearch.
AppSearch: Property: INSTALL_DIR_BASE, Signature: BasePath
AppSearch: Property: INSTALLDIR, Signature: InstallDir
Info 1402.Could not open key: HKEY_LOCAL_MACHINE\\Sample. System error 161. Verify that you have sufficient access to that key, or contact your support personnel.
Action ended 13:42:54: AppSearch. Return value 1.