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

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

问题描述

在每个组件一个文件"上阅读此答案后,使用WiX时,我很想知道在其他元素(包括ComponentDirectoryRegistry等)上使用KeyPath属性时的最佳做法是什么.

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"?如果是这样怎么办 不空吗?
  • 如果每个组件文件中的文件具有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 =是",在这种情况下,是在父组件上设置的.但这足以使安装程序检测/修复丢失的空文件夹吗?还是应该与注册表项一起使用?示例代码段:

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

目录元素没有KeyPath属性.

Directory element doesn't have a KeyPath attribute.

如果每个组件一个文件中的文件具有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",则该组件的安装目录将变为关键路径.当您在文件上进行显式设置时,显然该文件是关键路径

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的一般需要-检测组件.为什么需要额外的注册表项来检测文件系统上是否存在文件?当您为每个组件创建1个注册表项(即N个文件),然后让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天全站免登陆