I want to pass the install directory to my different custom actions. I have the property
<Property Id="CA1Action" Value="InstallDir=[INSTALLFOLDER]"/>
Then I defined a CA in Wix
<CustomAction Id="CA1Action"
BinaryKey="InstallerActionsBinary"
DllEntry="CA1"
Execute="commit"
Return="check" />
For completion, I call my CA as
<Custom Action="CA1Action" After="InstallFiles"></Custom>
Executing my installer with MSIEXEC, I get the following error message from my custom action which tries to open a file from the install:
Could not find file 'C:\Windows\Installer\MSICA8C.tmp-\C:\Program Files\MyProgram\web.config'.
Here is the way I am extracting information from the session:
public static ActionResult CA1(Session session_)
{
//Collect parameters from Session
CustomActionData data = session_.CustomActionData;
string path = data["InstallDir"];
}
My first question is why is the cache of the installer added to my parameter? To further add to my confusion, when I added
path = path.Substring("C:\Windows\Installer\MSICA8C.tmp-\".Length);
to my CA to remove "C:\Windows\Installer\MSICA8C.tmp-\", I get an argument exception telling me that the start value of the substring is higher than the length of my string ..So I added logging to my CA, and am seeing that path is getting set to '[INSTALLFOLDER]', not the value of the property, but then how is it the value of the property when I use it in the path for my FileStream?
I was following the replies in this post: How to pass parameters to the custom action?