WiX - 如何在安装过程中使用不同的复制策略 [英] WiX - How to have different copy strategies during installation

查看:28
本文介绍了WiX - 如何在安装过程中使用不同的复制策略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在安装过程中,我的应用程序将:

During installation, my application will:

步骤 A,查找 C:\WebService 目录.如果找到,请执行以下操作:

Step A, Look for C:\WebService directory. If found do following:

copy *.bat      --> C:\WebService\
copy boost*.dll --> C:\WebService\libs\
copy myApp.dll  --> C:\WebService\plugins\

步骤 B,如果没有找到,请执行以下操作:

Step B, If not found, do following:

copy *.bat --> [LocalAppData]\myApp\bin\
copy *.dll --> [LocalAppData]\myApp\libs\

我该怎么做?

我已经完成了第 2 步:

I had finished Step 2 by:

  1. 创建源目录:

  1. Create a source directory:

src\bin
src\libs

将文件复制到这些子目录

Copy files to these subdirs

使用heat扫描src目录,生成组到wxs文件中.

Use heat to scan the src directory and generate group into wxs file.

这里的问题是,对于步骤 A,我必须再次执行相同的操作.但是有大量的*.dll,将它们再次复制到另一个目录似乎不是一个好主意.

The problem here is, looks like for Step A, I have to do the same again. But there are tons of *.dll, copying them again to another directory doesn't look like a good idea.

推荐答案

好的,终于搞定了.

简而言之,我通过编写一个 C++ 程序来帮助实现这一点.

In short, I do this by writing a C++ program to help.

详情如下..

我的 wxs 开始是这样的:

My wxs starts like:

<Directory Id='TARGETDIR' Name='SourceDir'>
  <Directory Id='WebDir'>
      <Directory Id='INSTALLDIR' Name='$(var.ProductName)'/>
  </Directory>
  <Directory Id='DefaultDir'/>
</Directory>

现在使用heat来收集我的源目录以生成另一个用于candlelight链接的wxs文件

Now use heat to harvest my source directory to generate another wxs file for candle and light to link

然后是我的 C++ 程序,它被设计为

Then goes my C++ program, it was designed to

  1. 扫描整个生成的 wxs 文件以创建另一个目录结构.
  2. 替换目录、组件和文件的所有 ID,使其独一无二.
  3. 为所有新组件生成新的 GUID.
  4. 收集所有新组件 ID 以创建新组件组.

这个新的组件组可以有条件地引用安装,取决于是否有注册表项,或者是否找到目录,我的情况是:

This new component group can be referenced to be installed conditionally, depends on whether there is a registry key, or whether the directory is found, in my case it is:

  <Feature Id='RuntimeChrome' Level='1'>
    <Condition Level='0'>NOT INSTALLDIR_REGCU AND NOT INSTALLDIR_REGLM</Condition>
    <ComponentGroupRef Id='WebGroup' />
  </Feature>
  <Feature Id='RuntimeDefault' Level='1'>
    <ComponentGroupRef Id='DefaultGroup' />
  </Feature>

有了这些 wxs 文件,就可以在不同的场景下将包安装到不同的地方.

With these wxs files, the package can be installed into different places under different scenarios.

这篇关于WiX - 如何在安装过程中使用不同的复制策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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