使用 WiX 安装文件,无论版本号如何

发布于 2024-08-14 19:21:49 字数 458 浏览 3 评论 0原文

MyApp 版本 1.0 包含文件 foo.dll。该文件的版本为10.5.567。现在MyApp的版本是2.0,foo.dll的版本是2.0.123。该版本比旧版本低。编写此 dll 的供应商决定将文件版本号倒退。这不是我可以改变的决定。

如何让 WiX 始终安装该文件?

RemoveExistingProducts 操作安排在 InstallFinalize 操作之后,并且也无法更改。

InstallShield 有一个“始终覆盖”标志,但我认为如果不通过编译器开关更改所有文件的行为,我无法模仿它。我不想要这个。我只想更新这个文件。

我也尝试过

<RemoveFile Id="foo.dll" On="install" Name="foo.dll" />

但这也不起作用。后来我最终收到“错误 2753 文件 foo.dll 未标记为安装”。

MyApp version 1.0 contained the file foo.dll. The version of this file was version 10.5.567. Now MyApp is version 2.0 and the version of foo.dll is 2.0.123. The version is LOWER than the old version. The vendor who wrote this dll decided to go backwards with the file version number. This is not a decision I can change.

How do I get WiX to always install this file?

The RemoveExistingProducts action is scheduled after the InstallFinalize action and also cannot be changed.

InstallShield had an 'always overwrite' flag but I don't think I can mimic this without changing the behavior of all files via a compiler switch. I do not want this. I just want to update THIS ONE file.

I have also tried

<RemoveFile Id="foo.dll" On="install" Name="foo.dll" />

But this did not work either. I end up getting 'Error 2753 The file foo.dll is not marked for installation' later.

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

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

发布评论

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

评论(5

三寸金莲 2024-08-21 19:21:49

这篇文章已经有 10 年历史了,我们也遇到了这个问题,这真的很疯狂。其他方法对我们不起作用。

如何解决:

  1. 所有应该复制的文件,无论其版本如何,都必须位于其自己的组件中
  2. Component 元素必须具有唯一的 Guid,而不是 *
  3. Set KeyPath内部文件中的no element

示例:

<Component Id="cmpExample" Guid="{5ABE7229-C247-4CBA-B8DE-2C4968CD103E}" >
     <File Id="fileExample" KeyPath="no" Source="$(var.TargetDir)\SomeExample.dll" />
</Component>

我建议将所有这些 component 元素聚合到一个组件组中。此外,您可以使用 XML 转换 来摆脱这些如果您使用 heat.exe 收集所有文件。

使用此解决方案,即使安装的文件版本较高,您也可以复制文件。当升级时安装更高的文件版本时,它仍然可以按预期工作。

It is really crazy this post is 10 years old and we also have this problem. The other approaches did not work for us.

How to solve it:

  1. All files which should be copied regardless of their version, must be in their own component
  2. Component element must have a unique Guid, not a *
  3. Set KeyPath to no in the inner File element

Example:

<Component Id="cmpExample" Guid="{5ABE7229-C247-4CBA-B8DE-2C4968CD103E}" >
     <File Id="fileExample" KeyPath="no" Source="$(var.TargetDir)\SomeExample.dll" />
</Component>

I would recommend to aggregate all those component elements in a component group. And furthermore you can use XML Transformation to get rid of those files if you use heat.exe to harvest all your files.

With this solution you can copy the file, even if the installed file version is higher. And it still works as expected when a higher file version will be installed with your upgrade.

生来就爱笑 2024-08-21 19:21:49

这并不容易,因为它违反了 MSI 包的标准行为。编译时,必须在 light.exe 中使用 -sf 设置 supress-file-options。那么您读取的文件中就没有文件信息。您可以设置 DefaultVersion 该版本将被使用。
我还在解决方案中使用了 RemoveFile,但我可以说它有效。我已将其添加到添加文件的同一组件中。

   <Component>
        <File DiskId="1" Id="fooDLL" Name="foo.dll" Vital="yes" 
         DefaultVersion="$(var.MAJORVERSION).$(var.MINORVERSION).$(var.BUILDVERSION)" 
         DefaultLanguage="0"></File>
        <RemoveFile Id='RemoveOldDLL' On='install' Name='foo.dll'/>
   </Componente>

这不是一个干净的方法,但删除旧版本对我有用。

This isn't easy because it is against the standard behaviour of MSI-packages. When compiling, you have to set supress-file-options with -sf in light.exe. Then there are no file-informations from your files read. You can set DefaultVersion this version will be used.
I have also used RemoveFile in a solution, but i can say that it works. I have add it in same componente where i add the file.

   <Component>
        <File DiskId="1" Id="fooDLL" Name="foo.dll" Vital="yes" 
         DefaultVersion="$(var.MAJORVERSION).$(var.MINORVERSION).$(var.BUILDVERSION)" 
         DefaultLanguage="0"></File>
        <RemoveFile Id='RemoveOldDLL' On='install' Name='foo.dll'/>
   </Componente>

This is not a clean way, but to remove an old version it works for me.

冰之心 2024-08-21 19:21:49

前段时间我回答过类似的问题:
强制升级文件 我想我会使用一个配套文件来解决这个问题,但是您可能会收到验证错误,

因为有问题的文件是一个 dll,因此被视为可执行文件。我相信它仍然有效,而且可靠。

I answered a similar question a while back:
Forcing an upgrade of a file that is modified during its initial installation

I think I would use a companion file to solve this problem, but you might get validation errors since the file in question is a dll and hence considered an executable. I believe it would still work, and reliably so.

盛夏尉蓝 2024-08-21 19:21:49

注释

强制始终使用“InstallShield 技巧”覆盖 Light.exe 输出:

XPath="/wixOutput/table[@name='File']/row/field[5]" InnerText=„65535.0.0.0“

Annotation

Force always overwrite in Light.exe output with the "InstallShield trick":

XPath="/wixOutput/table[@name='File']/row/field[5]" InnerText=„65535.0.0.0“

我早已燃尽 2024-08-21 19:21:49

值得尝试的一件事是在序列的早期将RemoveExistingProducts设置为true。然后,MSI 应首先删除旧程序,然后安装升级程序。这将解决您的问题。例如

<InstallExecuteSequence>
    <RemoveExistingProducts After="CostFinalize" />
</InstallExecuteSequence>

One thing that could be worth trying is to set RemoveExistingProducts real early in the sequence. The MSI should then remove the old program first, then install the upgrade. This will solve your issue. e.g.

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