使用WiX,如何根据安装时可用的内容将单个文件安装到(可能)多个子目录?

时间:2021-03-20 22:43:31

I'm using WiX, and would like to know the .wxs necessary to take a file and install it to every available sub-directory of a particular location. This could mean 0 or more final installation locations, determined at install time based on the currently existing directory structure. For example, if I started the install with:

我正在使用WiX,并且想知道获取文件并将其安装到特定位置的每个可用子目录所需的.wx。这可能意味着0个或更多最终安装位置,在安装时根据当前存在的目录结构确定。例如,如果我使用以下命令启动安装:

\target
 \subdir-1
 \subdir-2

Then at the end of the installation my file would be in \subdir-1 and \subdir-2. If on the other hand these directories did not exist on the system when the install was started, my file would not be installed at all and no sub directories would be created.

然后在安装结束时,我的文件将在\ subdir-1和\ subdir-2中。另一方面,如果在启动安装时系统上不存在这些目录,则根本不会安装我的文件,也不会创建任何子目录。

3 个解决方案

#1


Afaik this is not possible with WiX (because it is basically against the nature of MSI to install a component into several locations).

对于WiX来说,这是不可能的(因为它基本上违背了将MSI安装到多个位置的MSI的性质)。

You could either

你可以

  • create a different component for each subfolder, or
  • 为每个子文件夹创建一个不同的组件,或

  • use a custom action to copy the component to all subfolders.
  • 使用自定义操作将组件复制到所有子文件夹。

In the latter case you should also provide a corresponding CA for uninstallation which removes all the files from the subfolders again.

在后一种情况下,您还应提供相应的CA以进行卸载,从而再次从子文件夹中删除所有文件。

EDIT: Seems my above answer is not totally correct. MSI supports duplicating files using the DuplicateFile tables and WiX 3.0 also provides a mechanism called "smart cabbing". Both are mentioned in a blog post by Aaron Stebner.

编辑:似乎我的上述答案并不完全正确。 MSI支持使用DuplicateFile表复制文件,WiX 3.0还提供了一种称为“智能cabbing”的机制。两者都在Aaron Stebner的博客文章中提到。

#2


Not without a custom action, you need to write a custom action that will do that.
The latest and greatest in custom actions is the DTF (and here) framework that comes with Wix3.

不是没有自定义操作,您需要编写一个自定义操作来执行此操作。最新和最好的自定义操作是Wix3附带的DTF(和此处)框架。

#3


If you are targeting Vista (or Win2k8, not sure about Win2k3), you can use mklink.

如果你的目标是Vista(或Win2k8,不确定Win2k3),你可以使用mklink。

#1


Afaik this is not possible with WiX (because it is basically against the nature of MSI to install a component into several locations).

对于WiX来说,这是不可能的(因为它基本上违背了将MSI安装到多个位置的MSI的性质)。

You could either

你可以

  • create a different component for each subfolder, or
  • 为每个子文件夹创建一个不同的组件,或

  • use a custom action to copy the component to all subfolders.
  • 使用自定义操作将组件复制到所有子文件夹。

In the latter case you should also provide a corresponding CA for uninstallation which removes all the files from the subfolders again.

在后一种情况下,您还应提供相应的CA以进行卸载,从而再次从子文件夹中删除所有文件。

EDIT: Seems my above answer is not totally correct. MSI supports duplicating files using the DuplicateFile tables and WiX 3.0 also provides a mechanism called "smart cabbing". Both are mentioned in a blog post by Aaron Stebner.

编辑:似乎我的上述答案并不完全正确。 MSI支持使用DuplicateFile表复制文件,WiX 3.0还提供了一种称为“智能cabbing”的机制。两者都在Aaron Stebner的博客文章中提到。

#2


Not without a custom action, you need to write a custom action that will do that.
The latest and greatest in custom actions is the DTF (and here) framework that comes with Wix3.

不是没有自定义操作,您需要编写一个自定义操作来执行此操作。最新和最好的自定义操作是Wix3附带的DTF(和此处)框架。

#3


If you are targeting Vista (or Win2k8, not sure about Win2k3), you can use mklink.

如果你的目标是Vista(或Win2k8,不确定Win2k3),你可以使用mklink。