English: How to Transfer Properties to Deferred Custom Action
Мы можем найти следующую информацию в MSDN. Где в последнем абзаце находим простое решение. Если его перевести на Wix-код, получим следующее (синим цветом выделено решение):
—–begin of test.wxs
<?xml version='1.0'?> <Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' > <Product Id='{00A86C83-0000-0000-0000-2FDF0595B100}' Name='Property to deffered custom action' Language='1033' Version='1.0.0.0' Manufacturer='Vlasenko' UpgradeCode='{00E9017B-0000-0000-0000-DDDF83756800}'> <Package Description="Property to a deffered custom action" Comments="http://vlasenko.org" InstallerVersion="300" Compressed="yes"/> <Media Id="1" Cabinet="_62E9A39FD9CC4E7436F7263EBE6CDCF4" EmbedCab="yes" /> <Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" /> <Directory Id="TARGETDIR" Name="SourceDir"> <Directory Id="ProgramFilesFolder"> <Directory Id="INSTALLDIR" Name="Property to deffered custom action"> <Component Id="first" Guid="*"> <File Id="test" DiskId="1" Name="test.wxs" Source="test.wxs" KeyPath="yes" /> </Component> </Directory> </Directory> </Directory> <Feature Id='Main' Title='Property to deffered custom action' Level='1'> <ComponentRef Id="first" /> </Feature> <CustomAction Id="ShowInstallDir.SetProperty" Property="ShowInstallDir" Value="[INSTALLDIR]" /> <CustomAction Id="ShowInstallDir" Script="vbscript" Execute="deferred"> <![CDATA[ Dim property property = Session.Property("CustomActionData") MsgBox property ]]> </CustomAction> <InstallExecuteSequence> <Custom Action="ShowInstallDir.SetProperty" Before="InstallInitialize">NOT REMOVE="ALL"</Custom> <Custom Action="ShowInstallDir" Before="InstallFinalize">NOT REMOVE="ALL"</Custom> </InstallExecuteSequence> </Product> </Wix>
end of test.wxs—–
To get msi-file:
- Download and install Wix.
- Save code to test.wxs
- Execute command candle test .wxs
- Execute command light -out test.msi test.wixobj
В следующий раз выложу код с реальным использованием этого решения (установка Apache httpd сервиса и генерация конфигурационного файла httpd.conf во-время инсталяции).