开发者

Correct way to implement Wix companion files?

开发者 https://www.devze.com 2023-01-21 15:32 出处:网络
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

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 Gu开发者_如何学Cid="*" 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号