Wix:在组件、目录、文件、注册表等上使用 KeyPath [英] Wix: Using KeyPath on Components, Directories, Files, Registry, etc, etc

查看:22
本文介绍了Wix:在组件、目录、文件、注册表等上使用 KeyPath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

阅读this answer每个组件一个文件"后使用 WiX 时的方法,我很想知道在其他元素(包括 ComponentDirectory、<代码>注册表等等等等

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:

  • 如果我有一个安装程序需要创建的空目录,我应该在 Directory 或其父 Component 上设置 KeyPath=yes"?如果是的话怎么办不是空的?
  • 如果在 file-per-component 场景中文件具有 KeyPath=yes",是将其设置在其父组件上的必要或良好做法?
  • 我在某处读到,不是在文件上设置 KeyPath,而是一个应该为每个文件使用一个注册表项并设置 KeyPath=yes"注册表元素...这是真的/有必要吗?
  • 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?

谢谢!

我知道 Directory 没有 KeyPath,但在我的问题中没有明确/详细说明.主要是,当必须创建一个空目录时,我对在组件上使用 KeyPath 感到好奇.我看到 KeyPath="yes";在这种情况下是在父组件上设置的.但这足以让安装程序检测/修复丢失的空文件夹吗?还是应该与注册表项一起使用?示例片段:

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>

推荐答案

一般来说,你应该根据KeyPath选项的主要思想来做决定.来自 MSDN:

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.

因此,如果您为每个组件编写 1 个文件,您将不会遇到意外删除文件并且修复未将其恢复的情况.如果您为每个组件编写 N 个文件,则无论如何您要么选择其中一个作为 KeyPath (WiX 文档鼓励您明确地这样做),要么添加一个额外的注册表项并让它是 KeyPath.

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.

回到你的问题:

如果我有一个安装程序需要创建的空目录,我应该在目录上设置 KeyPath="yes" 或

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

Directory 元素没有 KeyPath 属性.

如果文件在每个组件的文件方案中具有 KeyPath="yes",是将其设置在其父组件上的必要或良好做法?

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?

不,基本上,这没有意义.如果一个 组件KeyPath="yes",那么这个组件安装到的目录就成为一个关键路径.当您将其设置在 File 上时,显然该文件是关键路径.

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.

我在某处读到,不是在文件上设置 KeyPath,而是应该为每个文件使用一个注册表项并在注册表上设置 KeyPath="yes"元素...这真的是真的/有必要吗?

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?

这听起来像是胡说八道.同样,基于对 KeyPath 的一般需求 - 检测组件.为什么需要额外的注册表项来检测文件系统上是否存在文件?当您为每个组件(即 N 个文件)编写 1 个注册表项并让 Windows Installer 通过该注册表项判断该组件是否被视为未损坏"时,每个组件有 N 个文件的方案可能有意义.

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".

更新:您不必仅仅为了作为帮助安装程序跟踪空文件夹的关键路径而引入注册表项.把 KeyPath='yes' 添加到父组件就足够了.

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.

不要把事情复杂化.Windows Installer 本身就相当复杂.:)希望这会有所帮助.

Don't complicate things. Windows Installer is quite complex as it is. :) Hope this helps.

这篇关于Wix:在组件、目录、文件、注册表等上使用 KeyPath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆