title: Passing Dynamic Properties to Deferred Custom Actions WIX
body: <p>I want to pass the install directory to my different custom actions. I have the property</p>
  
  <pre><code>&lt;Property Id="CA1Action" Value="InstallDir=[INSTALLFOLDER]"/&gt;
  </code></pre>
  
  <p>Then I defined a CA in Wix</p>
  
  <pre><code>&lt;CustomAction Id="CA1Action"
            BinaryKey="InstallerActionsBinary"
            DllEntry="CA1"
            Execute="commit"
            Return="check" /&gt;
  </code></pre>
  
  <p>For completion, I call my CA as </p>
  
  <pre><code>&lt;Custom Action="CA1Action" After="InstallFiles"&gt;&lt;/Custom&gt;
  </code></pre>
  
  <p>Executing my installer with MSIEXEC, I get the following error message from my custom action which tries to open a file from the install:</p>
  
  <blockquote>
    <p>Could not find file 'C:\Windows\Installer\MSICA8C.tmp-\C:\Program Files\MyProgram\web.config'.</p>
  </blockquote>
  
  <p>Here is the way I am extracting information from the session:</p>
  
  <pre><code>public static ActionResult CA1(Session session_)
  {
          //Collect parameters from Session
          CustomActionData data = session_.CustomActionData;
          string path = data["InstallDir"];
  }
  </code></pre>
  
  <p>My first question is why is the cache of the installer added to my parameter? To further add to my confusion, when I added</p>
  
  <pre><code>path = path.Substring("C:\Windows\Installer\MSICA8C.tmp-\".Length);
  </code></pre>
  
  <p>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?</p>
  
  <p>I was following the replies in this post: <a href="https://stackoverflow.com/questions/27101579/how-to-pass-parameters-to-the-custom-action">How to pass parameters to the custom action?</a> </p>