WiX:如何防止将绑定文件的多个副本添加到 MSI?

发布于 2024-10-12 09:34:34 字数 2004 浏览 1 评论 0原文

我有一个安装程序,它链接了一个wixlib。 wixlib 将可执​​行文件安装到多个目录。

当我打开 wixlib 的“将文件绑定到库文件”(使用 -bf 开关)时,lit.exe 将可执行文件添加到 wixlib。但是,当我在 MSI 中链接 wixlib 时,可执行文件会多次添加到 MSI 文件中,从而导致安装程序大小膨胀。

当我关闭“将文件绑定到库文件中”时,问题不会发生(但显然,我需要设置 WiX 安装程序项目才能知道在哪里可以找到可执行文件,而不是在 wixlib 中查找)。

无论是否使用 -bf 开关,使用 orca 查看时最终的 MSI 文件看起来都很相似,因此我很难理解为什么第一种情况下的 MSI 需要包含多个副本。

wixlib wxs 文件如下所示:

<Fragment>

<ComponentGroup Id="cmpFoo1">
  <ComponentRef Id="cmpFooExe1" />
</ComponentGroup>

<DirectoryRef Id="TARGET_PATH1">
  <Component Id="cmpFooExe1" Guid="*">
    <File Id="filFooExe1" Name="foo.exe" KeyPath="yes" Source="$(var.source_path)\foo.exe" />
  </Component>
</DirectoryRef>

<ComponentGroup Id="cmpFoo2">
  <ComponentRef Id="cmpFooExe2" />
</ComponentGroup>

<DirectoryRef Id="TARGET_PATH2">
  <Component Id="cmpFooExe2" Guid="*">
    <File Id="filFooExe2" Name="foo.exe" KeyPath="yes" Source="$(var.source_path)\foo.exe" />
  </Component>
</DirectoryRef>

<Feature Id="ftFooFeatures" Level="1">
 <ComponentGroupRef Id="cmpFoo1"/>
 <ComponentGroupRef Id="cmpFoo2"/>
</Feature>

</Fragment>

安装程序 wxs 文件如下:

<Product Id="MyProduct" Name="ProductName" Language="1033" Version="1.0.0.0" Manufacturer="MyCompany" UpgradeCode="{UpgradeCode_Guid}">
<!-- ...etc... -->

<Directory Id="ROOT_TARGET_PATH" Name="Foo">
  <Directory Id="TARGET_PATH1" Name="Foo1" ComponentGuidGenerationSeed="{Guid1}" />
  <Directory Id="TARGET_PATH2" Name="Foo2" ComponentGuidGenerationSeed="{Guid2}" />
</Directory>

<Feature Id="ftMain" Level="1">
  <FeatureRef Id="ftFooFeatures" />
</Feature>

<!-- ...etc... -->
</Product>

预期最终安装列表将类似于: c:\foo\foo1\foo.exe c:'foo\foo2\foo.exe

有没有办法阻止 WiX(大概是链接器?)将 foo.exe 的多个副本添加到最终的 MSI 文件,同时仍然将 foo.exe 与 wixlib 绑定​​?

I have an installer, which links a wixlib. The wixlib installs an executable file to multiple directories.

When I turn on the "Bind files into the library file" for the wixlib (using the -bf switch), lit.exe adds the executable to the wixlib. However, when I link the wixlib in the MSI, the executable is added multiple times to the MSI file, bloating the installer size.

When I turn off "Bind files into the library file", the problem doesn't happen (but obviously, I need to setup the WiX installer project to know where to find the executable, rather than finding inside the wixlib).

With and without the -bf switch, the final MSI files look similar when viewed using orca, so I'm struggling to see why the MSI in the first case needs to including multiple copies.

The wixlib wxs file looks like:

<Fragment>

<ComponentGroup Id="cmpFoo1">
  <ComponentRef Id="cmpFooExe1" />
</ComponentGroup>

<DirectoryRef Id="TARGET_PATH1">
  <Component Id="cmpFooExe1" Guid="*">
    <File Id="filFooExe1" Name="foo.exe" KeyPath="yes" Source="$(var.source_path)\foo.exe" />
  </Component>
</DirectoryRef>

<ComponentGroup Id="cmpFoo2">
  <ComponentRef Id="cmpFooExe2" />
</ComponentGroup>

<DirectoryRef Id="TARGET_PATH2">
  <Component Id="cmpFooExe2" Guid="*">
    <File Id="filFooExe2" Name="foo.exe" KeyPath="yes" Source="$(var.source_path)\foo.exe" />
  </Component>
</DirectoryRef>

<Feature Id="ftFooFeatures" Level="1">
 <ComponentGroupRef Id="cmpFoo1"/>
 <ComponentGroupRef Id="cmpFoo2"/>
</Feature>

</Fragment>

And the installer wxs file like:

<Product Id="MyProduct" Name="ProductName" Language="1033" Version="1.0.0.0" Manufacturer="MyCompany" UpgradeCode="{UpgradeCode_Guid}">
<!-- ...etc... -->

<Directory Id="ROOT_TARGET_PATH" Name="Foo">
  <Directory Id="TARGET_PATH1" Name="Foo1" ComponentGuidGenerationSeed="{Guid1}" />
  <Directory Id="TARGET_PATH2" Name="Foo2" ComponentGuidGenerationSeed="{Guid2}" />
</Directory>

<Feature Id="ftMain" Level="1">
  <FeatureRef Id="ftFooFeatures" />
</Feature>

<!-- ...etc... -->
</Product>

The expectation is that the final installation listing would be something like:
c:\foo\foo1\foo.exe
c:'foo\foo2\foo.exe

Is there a way to prevent WiX (presumably the linker?) from adding multiple copies of foo.exe to the final MSI file, whilst still binding foo.exe with the wixlib?

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

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

发布评论

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

评论(2

依 靠 2024-10-19 09:34:34

WiX 有一项名为智能出租车。只要文件元素具有完全相同的源路径属性,WiX 就会自动为您执行此操作。

之前在 StackOverflow 上有人问过这个问题,但现在还太早,找不到它。 :-) 你可能会想要搜索并找到它,因为我记得问题是这样的:“我有相同的源路径,为什么它不起作用”Rob Mensching 加入了这个线程,但我不记得了决议是什么。

WiX has a feature called Smart Cabbing. WiX is supposed to automatically do this for you provided that the file elements have the exact same source path attribute.

This has been asked before on StackOverflow but it's too early in the morning to find it. :-) You will probably want to search and find it though because I remember the question being along the lines of "I have the same sourcepath, why isn't it working" Rob Mensching jumped in on the thread but I don't recall what the resolution was.

澉约 2024-10-19 09:34:34

我能想到的避免将 .exe 的多个副本放入安装程序的最好方法是使用 CopyFile 元素。

如果您考虑不仅复制安装的文件,还复制目标 PC 上存在的其他文件,请记住包含 RemoveFile 元素,因为此类文件不会被 Windows Installer 删除卸载时

The best thing I can think of to avoid multiple copies of the .exe being put into the installer is to use the CopyFile element.

If you consider copying not only the files you install, but also other files present on the target PC, remember to include RemoveFile element, because such files are not removed by Windows Installer on uninstall.

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