Wix: Using KeyPath on Components, Directories, Files, Registry, etc, etc

后端 未结 1 1543
有刺的猬
有刺的猬 2020-12-16 11:04

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

相关标签:
1条回答
  • 2020-12-16 11:27

    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 讨论(0)
提交回复
热议问题