在 wix 中更改我的组件 GUID?

发布于 2024-08-03 22:46:30 字数 462 浏览 6 评论 0 原文

什么时候应该更改或不更改 WIX 中的组件 GUID? Microsoft SDK 信息令人困惑

Glytzhkof 编辑:澄清一下,问题涉及何时应更改 MSI 组件的组件 GUID。组件可以在以下方面进行更改:更改目标路径、在同一组件中添加或删除文件、添加注册表数据等...这会导致所谓的组件引用(即 在 MSI 中创建组件的最佳实践

When should I change or not change my component GUID in WIX? The Microsoft SDK information is confusing.

Glytzhkof edit: To clarify, the question deals with when a component GUID should be changed for an MSI component. A component can change with aspects such as: changed destination path, addition or removal of files to/from the same component, addition of registry data etc... This causes problems with regards to the so called component referencing, i.e the best practice for creating components in MSI.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

舟遥客 2024-08-10 22:46:30

MSI 的总体概念是,之间存在1:1 映射
组件 GUID(唯一标识符)和绝对路径
(安装位置/关键路径)。完整路径,包括文件名(如果)
任意(目录可以是组件的关键路径)。请参阅下面的更新,了解新的 Wix 功能,以自动神奇地进行处理
有了这个。


Rob Mensching(WiX 作者):

有关组件规则的更多信息:


我使用一些简单规则来处理过于复杂且相当违反直觉的组件规则(特别是对于开发人员而不是部署专家):

  • 始终为每个文件使用单独的组件(即使对于非二进制文件)。这样就避免了各种问题。有一些例外:
    • 多文件 .NET 程序集应全部位于一个组件中,因为它们应始终作为一个单元进行安装/卸载。
    • 其他一些常规文件类型出现在“匹配对”中 - 它们属于同一组。通常这些是内容和索引文件。例如,考虑 Microsoft 帮助文件:
      • .HLP 和 .CNT 文件属于同一类。
      • .CHM 和 .CHI 文件属于同一类。
    • 可能有多个此类文件类型属于同一组,因此应该放在同一组件中,以便它们一起安装/卸载 - 我怀疑某些证书文件是候选文件。很难拿出一个明确的清单。只需问自己“这些文件是否总是属于一起” - 这样每当有新版本时它们总是成对出现?如果是,则通过同一组件安装它们。将版本控制文件(如果有)设置为密钥文件。
    • 我想添加驱动程序文件作为始终属于在一起的一堆文件的示例:SampleDriver.cat<代码>SampleDriver.infSampleDriver.sysSampleDriver.cer。它们必须作为一个“单元”全部匹配才能部署。
  • 请记住,一旦为组件分配了 GUID,它就固定为该组件的关键路径(绝对路径)。如果将文件移动到新位置或重命名该文件,请为其指定一个新的组件 GUID(因为绝对路径不同,所以它实际上是一个新标识)。
  • 总之,组件 GUID 与绝对安装位置相关联,而不是与特定文件相关联。 如果文件移动,GUID 不会跟随文件移动。 GUID 引用计算的是绝对位置,而不是文件本身。
  • 不要在现有组件中添加或删除文件。由此产生各种升级和修补问题。这就是为什么我通常喜欢每个组件一个文件。
  • 组件引用还有很多内容,但我将仅作“概述”。

一些示例:

  • 将文件 C:\Program Files\MyCompany\MyApp\MyFile.exe 重命名为 C:\Program Files\MyCompany\MyApp\MyFile_NEW.exe。这对于组件创建意味着什么?这是一个新的绝对安装路径,因此您可以为托管组件生成一个新的 GUID,或者添加一个新组件并删除旧组件(具有相同的效果)。
  • 更新后的 MSI 提供了新版本的 MyFile.exe。该位置与以前相同,这意味着组件 GUID 不应更改。这是相同的文件(身份),只是版本不同。

更新

自动组件 GUID:WIX 现在有一个新的 自动生成组件 GUID 功能,计算 GUID 只要目标路径
保持不变。说实话,我还没有尝试过,但很多人似乎
毫无问题地使用它,并且 Rob Mensching(Wix 作者)表示正常使用是安全的。作为一个概念,我强烈推荐这个
因为它具有一些自动魔法并保护你免受某些
复杂性。

最小 WiX 标记:另请注意,您可以离开从中提取出很多源属性
你的 Wix xml 文件
并依赖 Wix 默认值而不是硬性的
编码值。

The overall concept of MSI is that there is a 1:1 mapping between
a component GUID (unique identifier) and an absolute path
(install location / key path). The full path, including file name if
any (a directory can be the key path for a component). See update below for a new Wix feature to deal auto-magically
with this.


Rob Mensching (WiX author):

More on Component Rules:


I use some simple rules to deal with the overly complex and rather counterintuitive component rules (especially for developers as opposed to deployment specialists):

  • Always use a separate component per file (even for non-binaries). This avoids all kinds of problems. There are a few exceptions:
    • Multi-file .NET assemblies should all be in one component since they should always be installed / uninstalled as a single unit.
    • A few other, general file types come in "matching pairs" - they belong together. Often these are content and index files. As an example consider Microsoft help files:
      • .HLP and .CNT files belong together.
      • .CHM and .CHI files belong together.
    • There are likely several such file types that belong together and should hence be put in the same component so they install/uninstall together - I suspect certain certificate files to be candidates. It is hard to come up with a definite list. Simply ask yourself "do these files always belong together" - so they always show up in pairs whenever there is a new version? If yes, then install them via the same component. Set the versioned file, if any, as key file.
    • I want to add driver files as an example of a bunch of files always belonging together: SampleDriver.cat, SampleDriver.inf, SampleDriver.sys, SampleDriver.cer. They must all match as a "unit" for deployment.
  • Remember that once you have allocated a GUID for a component, it's set in stone for that component's key path (absolute path). If you move the file to a new location or rename the file, give it a new component GUID (since the absolute path is different it's effectively a new identity).
  • In summary component GUIDs are tied to an absolute installation location, and not to a specific file. The GUID doesn't follow the file around if it moves. The GUID reference counts an absolute location, not the file per se.
  • Do not add or remove files from an existing component. All sorts of upgrade and patching problems result. This is why I like one file per component as a general rule.
  • There is a lot more to component referencing, but I will leave it at that for an "overview".

Some samples:

  • You rename the file C:\Program Files\MyCompany\MyApp\MyFile.exe to C:\Program Files\MyCompany\MyApp\MyFile_NEW.exe. What does this mean for component creation? This is a new absolute installation path, so you generate a new GUID for the hosting component, OR you add a new component and delete the old one (which has the same effect).
  • Your updated MSI delivers a new version of MyFile.exe. The location is the same as before, this means the component GUID should not change. It is the same file (identity), just in a different version.

UPDATE:

Auto Component-GUIDs: WIX now has a new auto-generate component GUID feature that calculates a GUID as long as the target path
stays the same. I have not tried this out to be honest, but many seem
to use it without problems, and Rob Mensching (Wix author) states it is safe for normal use. As a concept I highly recommend this
since it features some auto-magic and shields you from some
complexity.

Minimal WiX Markup: Also note that you can leave out a lot of source attributes from
your Wix xml file
and rely on Wix defaults instead of hard
coding values.

春风十里 2024-08-10 22:46:30

您永远不会更改 Component/@Guid。您也永远不会更改组件中的资源集(文件、RegistryKey、快捷方式、TypeLib 等)。当你有一个新的资源时,你必须使用新的@Guid创建一个新的组件。真正棘手的部分是新组件不能与旧组件重叠(例如文件路径、注册表项路径或 typelib 等)。

这些基本上是组件规则,请查看:https:// /robmensching.com/blog/posts/2003/10/18/component-rules-101/

You never change the Component/@Guid. You also never change the set of Resources (File, RegistryKey, Shortcut, TypeLib, etc.) in the Component. When you have a new Resource, you must create a new Component with a new @Guid. The really tricky part is that new Component can have no overlap (think file path, or registry key path, or typelib, etc.) with the old Component.

These are basically the Component Rules, check out: https://robmensching.com/blog/posts/2003/10/18/component-rules-101/.

葬花如无物 2024-08-10 22:46:30

Have a look at the WiX Tutorial, The Files Inside, for a detailed explanation on component rules. Basically, it says you never change the GUID of a component, since that means orphaning the old component and creating a new component.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文