Wix Optimization
<p>I was reviewing some statements which came from the dark.exe decompiled output of an installshield msi file.</p>

<p>One section, for an example:</p>

<pre><code>&lt;Directory Id='INSTALLDIR' Name="$(var.BasicProductName)"&gt;
    ...
&lt;Component Id="Comp1" Guid="xx" KeyPath="yes" SharedDllRefCount="yes" Win64="$(var.Win64)"&gt;
    &lt;CreateFolder Directory="INSTALLDIR" /&gt;
    ...
&lt;/Component&gt;
&lt;Component Id="Comp2" Guid="xx" KeyPath="yes" SharedDllRefCount="yes" Win64="$(var.Win64)"&gt;
    &lt;CreateFolder Directory="INSTALLDIR" /&gt;
    ...
&lt;/Component&gt;
&lt;Directory Id="UHDDRIVER" Name="UHDDriver"&gt;
    &lt;Component Id="MyUHD" Guid="xx" SharedDllRefCount="yes" Win64="$(var.Win64)"&gt;
        &lt;File Id="MyUHD.inf" Name="MyUHD.inf" KeyPath="yes" Vital="no" DiskId="1" Source="$(var.WIN64BINARIES)\UHDDriver\MyUHD.inf" /&gt;
        &lt;File Id="MyUHD_.cat" Name="MyUHD_.cat" Vital="no" DiskId="1" Source="$(var.WIN64BINARIES)\UHDDriver\MyUHD_.cat" /&gt;
        &lt;Driver AddRemovePrograms="no" DeleteFiles="yes" Legacy="yes" PlugAndPlayPrompt="no" Sequence="2" xmlns="http://schemas.microsoft.com/wix/DifxAppExtension" /&gt;
    &lt;/Component&gt;
    &lt;Component Id="UHDDriver_Dir" Guid="xx" KeyPath="yes" SharedDllRefCount="yes" Win64="$(var.Win64)"&gt;
        &lt;CreateFolder Directory="UHDDRIVER" /&gt;
    &lt;/Component&gt;
    &lt;Directory Id="AMD644" Name="AMD64"&gt;
        &lt;Component Id="MyUHD_AMD64" Guid="xx" KeyPath="yes" SharedDllRefCount="yes" Win64="$(var.Win64)"&gt;
            &lt;File Id="MyUHD.sys1" Name="MyUHD.sys" Vital="no" DiskId="1" Source="$(var.WIN64BINARIES)\UHDDriver\AMD64\MyUHD.sys" /&gt;
        &lt;/Component&gt;
    &lt;/Directory&gt;
    &lt;Directory Id="X864" Name="x86"&gt;
        &lt;Component Id="MyUHD_x86" Guid="xx" KeyPath="yes" SharedDllRefCount="yes" Win64="$(var.Win64)"&gt;
            &lt;File Id="MyUHD.sys" Name="MyUHD.sys" Vital="no" DiskId="1" Source="$(var.WIN64BINARIES)\UHDDriver\X86\MyUHD.sys" /&gt;
        &lt;/Component&gt;
    &lt;/Directory&gt;
&lt;/Directory&gt;
&lt;/Directory&gt;
</code></pre>

<p>Wondering if I can optimize the <code>CreateFolder</code> tags as follows:</p>

<pre><code>&lt;Directory Id='INSTALLDIR' Name="$(var.BasicProductName)"&gt;
    ...
&lt;Component Id="Comp1" Guid="xx" KeyPath="yes" SharedDllRefCount="yes" Win64="$(var.Win64)"&gt;
    &lt;CreateFolder /&gt;
    ...
&lt;/Component&gt;
&lt;Component Id="Comp2" Guid="xx" KeyPath="yes" SharedDllRefCount="yes" Win64="$(var.Win64)"&gt;
    ...
&lt;/Component&gt;
&lt;Directory Id="UHDDRIVER" Name="UHDDriver"&gt;
    &lt;Component Id="MyUHD" Guid="xx" SharedDllRefCount="yes" Win64="$(var.Win64)"&gt;
        &lt;CreateFolder /&gt;
        &lt;File Id="MyUHD.inf" Name="MyUHD.inf" KeyPath="yes" Vital="no" DiskId="1" Source="$(var.WIN64BINARIES)\UHDDriver\MyUHD.inf" /&gt;
        &lt;File Id="MyUHD_.cat" Name="MyUHD_.cat" Vital="no" DiskId="1" Source="$(var.WIN64BINARIES)\UHDDriver\MyUHD_.cat" /&gt;
        &lt;Driver AddRemovePrograms="no" DeleteFiles="yes" Legacy="yes" PlugAndPlayPrompt="no" Sequence="2" xmlns="http://schemas.microsoft.com/wix/DifxAppExtension" /&gt;
    &lt;/Component&gt;
    &lt;Directory Id="AMD644" Name="AMD64"&gt;
        &lt;Component Id="MyUHD_AMD64" Guid="xx" KeyPath="yes" SharedDllRefCount="yes" Win64="$(var.Win64)"&gt;
            &lt;File Id="MyUHD.sys1" Name="MyUHD.sys" Vital="no" DiskId="1" Source="$(var.WIN64BINARIES)\UHDDriver\AMD64\MyUHD.sys" /&gt;
        &lt;/Component&gt;
    &lt;/Directory&gt;
    &lt;Directory Id="X864" Name="x86"&gt;
        &lt;Component Id="MyUHD_x86" Guid="xx" KeyPath="yes" SharedDllRefCount="yes" Win64="$(var.Win64)"&gt;
            &lt;File Id="MyUHD.sys" Name="MyUHD.sys" Vital="no" DiskId="1" Source="$(var.WIN64BINARIES)\UHDDriver\X86\MyUHD.sys" /&gt;
        &lt;/Component&gt;
    &lt;/Directory&gt;
&lt;/Directory&gt;
&lt;/Directory&gt;
</code></pre>

<p>Note that I removed the component Id <code>UHDDriver_Dir</code> and replaced it with a <code>CreateFolder</code> tag in the first component, thinking that an empty <code>CreateFolder</code> simply operates on the last known <code>Directory</code> tag - is that correct?  Am I okay for install/uninstall to remove that component, or do I need a defined component and guid for each dir I create?</p>

<p>Are there other optimizations I am missing here?</p>