实现 Wix 伴随文件的正确方法?

发布于 2024-09-29 02:35:12 字数 1477 浏览 2 评论 0原文

我们目前正在将构建脚本从 3.0 升级到 3.5,并在此过程中修复一堆旧的 ICE 错误。我已经阅读了许多文章,但对于使用伴随文件的最佳方法通常是什么,我有点困惑。

现在,假设文件 A.manifest 是 A.exe 的伴随文件...

最初:我们的旧版本将这 2 个文件分为 2 个组件:

<Component Guid="*" Id="A.exe" SharedDllRefCount="yes">
    <File Id="..." KeyPath="yes" Source="A.exe"/>
</Component>
<Component Guid="*" Id="A.exe.manifest" SharedDllRefCount="yes">
    <File CompanionFile="A.exe" Id="..." Source="A.exe.manifest"/>
</Component>

这会触发 ICE54:警告组件 'A .exe.manifest'使用文件'A.exe.manifest'作为其KeyPath,但文件的版本是由文件'A.exe'提供的,所以我猜这显然是错误的。

第一种方法:所以我尝试将KeyPath=yes添加到同伴的目录中:

<Component .../>
<Component Guid="*" Id="A.exe.manifest" SharedDllRefCount="yes" KeyPath="yes">
    <File CompanionFile="A.exe" Id="..." Source="A.exe.manifest"/>
</Component>

这会抑制警告,但在 Orca 中组件的 KeyPath 列显示为空白,所以我有怀疑它是否正确?

第二种方法: 接下来我尝试组合组件:

<Component Guid="*" Id="A.exe" SharedDllRefCount="yes"> <!-- GUID is wrong! -->
    <File Id="..." KeyPath="yes" Source="A.exe"/>
    <File CompanionFile="A.exe" Id="..." Source="A.exe.manifest"/>
</Component>

但似乎允许 WiX 在此处自动生成 GUID 不起作用。但如果我手动生成 GUID,每次构建都会在升级时破坏组件规则!我们实际上部署了很多伴随文件,因此生成每个组件的哈希值并永久存储它也可能是不可行的。对于每个伴随文件使用虚拟注册表项也是如此。

TLDR:这两种方法中哪一种实际上是 WiX 中更好的实践?

We're currently in the process of upgrading our build scripts from 3.0 to 3.5, and fixing a bunch of old ICE errors along the way. I've read through a number of articles, but I'm slightly confused as to what is usually the best approach to using companion files.

Now, assuming File A.manifest is a companion file to A.exe...

Originally: our old build breaks up the 2 files in 2 components:

<Component Guid="*" Id="A.exe" SharedDllRefCount="yes">
    <File Id="..." KeyPath="yes" Source="A.exe"/>
</Component>
<Component Guid="*" Id="A.exe.manifest" SharedDllRefCount="yes">
    <File CompanionFile="A.exe" Id="..." Source="A.exe.manifest"/>
</Component>

Which triggers ICE54: WARNING Component 'A.exe.manifest' uses file 'A.exe.manifest' as its KeyPath, but the file's version is provided by the file 'A.exe', so I guess it's obviously wrong.

1st approach: So I tried adding KeyPath=yes to the companion's directory:

<Component .../>
<Component Guid="*" Id="A.exe.manifest" SharedDllRefCount="yes" KeyPath="yes">
    <File CompanionFile="A.exe" Id="..." Source="A.exe.manifest"/>
</Component>

This suppresses the warning, but in Orca the KeyPath column of the component shows as blank, so I have doubts it's correct?

2nd approach: Next I tried combining the components:

<Component Guid="*" Id="A.exe" SharedDllRefCount="yes"> <!-- GUID is wrong! -->
    <File Id="..." KeyPath="yes" Source="A.exe"/>
    <File CompanionFile="A.exe" Id="..." Source="A.exe.manifest"/>
</Component>

But it seems that allowing WiX to automatically generate the GUIDs here wouldn't work. But if I have the GUIDs manually generated, each time we build it would break component rules when upgrading! We actually deploy a lot of companion files, so generating a hash of each component and permanently storing it might be unfeasible too. Ditto for using a dummy registry key for each companioned file.

TLDR: Which of the 2 approaches is actually the better practice in WiX?

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

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

发布评论

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

评论(1

不及他 2024-10-06 02:35:12

我的问题是你这样做想解决什么问题?一般来说,除非您对组件规则以及使用/不使用伴随文件的服务影响有非常深入的了解,否则您可能应该坚持 1:1 的组件:文件比率,其中所有文件都是关键文件。这不是绝对规则,但可能是 95-99% 的最佳规则。

也就是说,请查看 File 元素上的 KeyPath 属性,并记住,当组件在 MSI 的 KeyPath 列中没有数据时,这意味着组件目录是关键路径。

My question would be what problem are you trying to solve in doing this? In general, unless you have a really strong understanding of the component rules and the servicing implications of using/not using companion files, you should probably stick to a 1:1 component:file ratio where all files are key files. This is not an absolute rule but it's probably 95-99% optimal.

That said, take a look at the KeyPath attribute on the File element and remember that when a component doesn't have data in the KeyPath column of the MSI, that means the components directory is the key path.

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