Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7852699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:29:07+00:00 2026-06-02T19:29:07+00:00

After reading this answer on "one file per component" approach when using WiX, I

  • 0

After reading this answer on "one file per component" approach when using WiX, I was curious to find out what are the best practices when using KeyPath attribute on other elements including Component, Directory, Registry etc, etc.

I am interested in any general suggestion, but here are a couple of concrete questions:

  • If I have an empty directory that installer needs to create should I
    set KeyPath="yes" on Directory or its parent Component? What if it is
    not empty?
  • If a File has KeyPath="yes" in a file-per-component scenario, is it
    necessary or good practice to set it on its parent Component?
  • I read somewhere that instead of setting KeyPath on a File, one
    should use a Registry key for each File and set KeyPath="yes" on
    Registry element…Is that really true/necessary?

Thanks!

Edit #1 – Clarification re: Directory

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="yes" 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:

<Directory Id="LOGS" Name="Logs">
  <Component Id="LogsDir" Guid="*" KeyPath="yes">
    <CreateFolder Directory="LOGS" />
  </Component>
</Directory>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T19:29:11+00:00Added an answer on June 2, 2026 at 7:29 pm

    In general, you should base your decision on the main idea of KeyPath option. From MSDN:

    This value points to a file or folder belonging to the component that
    the installer uses to detect the component.

    So, if you author 1 file per component, you won’t face the situation when you accidentally deleted a file and repair didn’t bring it back. If you author N files per component, you’ll anyway either select one of them to be a KeyPath (and WiX docs encourage you to do this explicitly), or you add an extra registry entry and let it be the KeyPath.

    Back to your questions:

    If I have an empty directory that installer needs to create should I
    set KeyPath=”yes” on Directory or

    Directory element doesn’t have a KeyPath attribute.

    If a File has KeyPath=”yes” in a file-per-component scenario, is it
    necessary or good practice to set it on its parent Component?

    No, basically, this doesn’t make sense. If a Component has KeyPath="yes", then the directory this component is installed to becomes a key path. When you set it on a File explicitly, then obviously the file is a key path.

    I read somewhere that instead of setting KeyPath on a File, one should
    use a Registry key for each File and set KeyPath=”yes” on Registry
    element…Is that really true/necessary?

    This sounds like nonsense. Again, base on the general need for KeyPath – detect the component. Why do you need an extra registry entry to detect whether a file is there on a file system? It might make sense for N files per component scenario, when you author 1 registry entry per component (that is N files), and let Windows Installer judge by that registry entry, whether the component is considered “not broken”.

    UPDATE: You don’t have to introduce a registry entry just to serve as a key path to help installer tracking an empty folder. It is enough if you add KeyPath='yes' to the parent component.

    Don’t complicate things. Windows Installer is quite complex as it is. 🙂
    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After reading this answer: best way to pick a random subset from a collection?
After reading this question , i saw the answer by Naveen containing a link
After reading this discussion and this discussion about using CrashRpt to generate a crash
After reading the answer to this question , I learned that SFINAE can be
I have this question after reading the answer here , what's the difference at
I'm trying to understand how to use Type Converters after reading this answer to
Edit: After reading the responses, I believe the answer is don't do this, hence
After reading this answer , it looks like it is a best practice to
This question came to mind after reading the answer to this question; which basically
I'm asking this question after reading this answer on StackOverflow. The supplied answer works

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.