WiX:如何防止将绑定文件的多个副本添加到 MSI? [英] WiX: How do I prevent multiple copies of a bound file being added to an MSI?

查看:26
本文介绍了WiX:如何防止将绑定文件的多个副本添加到 MSI?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

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.

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

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).

使用和不使用 -bf 开关,使用 orca 查看时最终的 MSI 文件看起来很相似,所以我很难理解为什么第一种情况下的 MSI 需要包含多个副本.

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.

wixlib wxs 文件如下所示:

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>

安装程序 wxs 文件如下:

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>

期望最终的安装清单类似于:c:\foo\foo1\foo.exec:'foo\foo2\foo.exe

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

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

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?

推荐答案

WiX 有一个名为 智能出租车.如果文件元素具有完全相同的源路径属性,WiX 应该会自动为您执行此操作.

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.

之前在 StackOverflow 上也有人问过这个问题,但是早上找不到它.:-) 你可能想搜索并找到它,因为我记得问题是我有相同的源路径,为什么它不起作用"Rob Mensching 加入了线程,但我不记得了分辨率是多少.

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.

这篇关于WiX:如何防止将绑定文件的多个副本添加到 MSI?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆