Reputation: 73
What am I doing wrong??
Please, if your answer is that I should be using the builtin service installing stuff in WiX, don't bother answering. It doesn't work very well for me and I don't want to go applying XSLT transforms to my HEATed .wxs files.
According to my log, it's doing both of the custom actions but InstallAndStartServices tells me "INSTALLFOLDER" is not in the session.CustomActionData dictionary.
<Binary Id="ServiceInstaller" SourceFile="DeploymentItems\ServiceInstaller.CA.dll" />
<CustomAction Id="SetInstallFolderForCA" Property="InstallAndStartServices" Value="INSTALLFOLDER=[INSTALLFOLDER]" Execute="immediate" Return="check" />
<CustomAction Id="InstallAndStartServices" BinaryKey="ServiceInstaller" DllEntry="InstallAndStartServices" Execute="immediate" Return="check" />
<InstallExecuteSequence>
<Custom Action="SetInstallFolderForCA" After="InstallFiles">NOT Installed</Custom>
<Custom Action="InstallAndStartServices" After="SetInstallFolderForCA"/>
</InstallExecuteSequence>
MSI (s) (78:DC) [15:31:47:745]: PROPERTY CHANGE: Adding InstallAndStartServices property. Its value is 'INSTALLFOLDER=C:\Program Files\My Product\'.
MSI (s) (78:DC) [15:31:47:745]: Doing action: InstallAndStartServices
MSI (s) (78:DC) [15:31:47:745]: Note: 1: 2205 2: 3: ActionText
Action start 15:31:47: InstallAndStartServices.
Begin InstallServices
Exception thrown by custom action: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Microsoft.Deployment.WindowsInstaller.CustomActionData.get_Item(String key)
string installFolder = session.CustomActionData["INSTALLFOLDER"];
Upvotes: 0
Views: 1886
Reputation: 55601
See:
Deployment Tools Foundation (DTF) Managed Custom Actions
Note: For the purpose of brevity, this blog post is going to assume that the reader already has a strong understanding of the Windows Installer architecture and philosophy. I will not attempt to fully cover the declarative and transactional design goals of MSI or the sordid details of the pro’s and con’s of different custom action types. If you do not have this knowledge, I highly advise that you obtain it prior to writing custom actions for Windows Installer packages.
Installation Phases and In-Script Execution Options for Custom Actions in Windows Installer
Abstract: When creating a custom action in InstallShield Professional - Windows Installer Edition you have several in-script execution options to choose from:
•Immediate execution
•Deferred execution
•Rollback execution
•Commit execution
•Deferred execution in System
Context
This article explains what these options mean and how they affect in which phase your custom action is executed at installation run time. It also helps you to insert the custom action in the correct location in the user interface or execute sequence, in order to avoid error messages like "Cannot write script record. Transaction not started."
Upvotes: 3