title: Dynamically set install dir in WiX from environment variable
body: <p>I'm new to MSI development (with WiX or otherwise) and I'm trying to read the value of an environment variable and use it as the installation directory. My msi is gui-less too and giving the user to override the path is not permitted.</p>
  
  <p>I can successfully read the var with:</p>
  
  <pre><code>&lt;SetProperty 
      Id="TARGETINSTALLDIR" 
      Value="[%MY_ENV_VAR]\My\Install\Path" 
      After="LaunchConditions" 
      Sequence="first"  /&gt;
  </code></pre>
  
  <p>I can see in the msi logs the correct path retrieved. </p>
  
  <p>I have tried the following to set the returned path:</p>
  
  <pre><code>&lt;Directory Id="TARGETDIR" Name="SourceDir"&gt;
      &lt;Directory Id="APPLICATIONROOTDIRECTORY" Name="[TARGETINSTALLDIR]"/&gt;
  &lt;/Directory&gt;
  </code></pre>
  
  <p>Also,</p>
  
  <pre><code>&lt;Directory Id="TARGETDIR" Name="SourceDir"&gt;
      &lt;Directory Id="APPLICATIONROOTDIRECTORY" Name="TARGETINSTALLDIR"/&gt;
  &lt;/Directory&gt;
  </code></pre>
  
  <p>Failing that, I also tried to read the directory path within the ROOT Directory as shown below</p>
  
  <pre><code>&lt;Directory Id="TARGETDIR" Name="SourceDir"&gt;
      &lt;Directory Id="ROOT" Name="[%MY_ENV_VAR]"&gt;
        &lt;Directory Id="My" Name="My"&gt;
          &lt;Directory Id="Install" Name="Install"&gt;
            &lt;Directory Id="APPLICATIONROOTDIRECTORY" Name="Path"/&gt;
          &lt;/Directory&gt;
        &lt;/Directory&gt;  
      &lt;/Directory&gt;
  &lt;/Directory&gt;
  </code></pre>
  
  <p>Is there some syntax I'm missing or am I fundamentally misunderstanding how this should be done?</p>