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"];