title: Wix: Using KeyPath on Components, Directories, Files, Registry, etc, etc
body: <p>After reading <a href="https://stackoverflow.com/a/1604348/481904">this answer</a> on &quot;one file per component&quot; approach when using WiX, I was curious to find out what are the best practices when using <code>KeyPath</code> attribute on other elements including <code>Component</code>, <code>Directory</code>, <code>Registry</code> etc, etc.</p>
  <p>I am interested in any general suggestion, but here are a couple of concrete questions:</p>
  <ul>
  <li>If I have an empty directory that installer needs to create should I
  set <code>KeyPath=&quot;yes&quot;</code> on <code>Directory</code> or its parent <code>Component</code>? What if it is
  not empty?</li>
  <li>If a File has <code>KeyPath=&quot;yes&quot;</code> in a file-per-component scenario, is it
  necessary or good practice to set it on its parent Component?</li>
  <li>I read somewhere that instead of setting <code>KeyPath</code> on a File, one
  should use a Registry key for each File and set <code>KeyPath=&quot;yes&quot;</code> on
  Registry element...Is that really true/necessary?</li>
  </ul>
  <p>Thanks!</p>
  <h1>Edit #1 - Clarification re: <code>Directory</code></h1>
  <p>I was aware of Directory not having KeyPath, but was not explicit/detailed in my question.
  Mainly, I was curious about the usage of KeyPath on a Component when an empty directory has to be created. I am seeing that KeyPath=&quot;yes&quot; is in such case being set on the parent Component. But is that enough for the installer to detect/repair missing empty folder? Or should it be used along with registry entry? Example snippet:</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;Directory Id=&quot;LOGS&quot; Name=&quot;Logs&quot;&gt;
    &lt;Component Id=&quot;LogsDir&quot; Guid=&quot;*&quot; KeyPath=&quot;yes&quot;&gt;
      &lt;CreateFolder Directory=&quot;LOGS&quot; /&gt;
    &lt;/Component&gt;
  &lt;/Directory&gt;
  </code></pre>