我有一个安装程序,它链接了一个wixlib。wixlib将可执行文件安装到多个目录。
当我打开wixlib的"Bind files into the library file“(使用-bf开关)时,lit.exe将可执行文件添加到wixlib。但是,当我链接MSI中的wixlib时,可执行文件被多次添加到MSI文件中,这增加了安装程序的大小。
当我关闭“将文件绑定到库文件”时,问题并没有发生(但显然,我需要设置WiX installer项目来知道在哪里可以找到可执行文件,而不是在wixlib中查找)。
无论是否使用-bf开关,最终的MSI文件在使用orca查看时看起来都很相似,所以我很难理解为什么第一种情况下的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绑定?
发布于 2011-01-18 21:30:44
WiX有一个名为Smart Cabbing的功能。只要文件元素具有完全相同的源路径属性,WiX就会自动为您完成此操作。
这个问题以前也曾在StackOverflow上被问过,但现在找到它还为时过早。:-)你可能想要搜索并找到它,因为我记得问题是这样的:“我有相同的源路径,为什么它不工作”Rob Mensching跳到了线程上,但我不记得解决方案是什么。
发布于 2011-01-18 18:11:03
为了避免将多个.exe副本放入安装程序中,我能想到的最好方法就是使用CopyFile元素。
如果您不仅要复制安装的文件,还要复制目标PC上的其他文件,请记住要包含RemoveFile元素,因为such files are not removed by Windows Installer on uninstall。
https://stackoverflow.com/questions/4721266
复制相似问题