在WiX中收集多个目录 [英] Harvesting multiple directories in WiX

查看:218
本文介绍了在WiX中收集多个目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个包含许多功能的安装程序,并且我正在使用 heat 来收集每个功能的文件目录.
我的源目录结构如下所示:

I'm trying to build an installer that includes a number of features and I'm using heat to harvest a directory of files for each feature.
My source directory structure looks something like this:

HarvestDir
          \FeatureA
                   \FeatureImpl.dll
                   \FeatureImpl2.dll
          \FeatureB
                   \FeatureImpl.dll
                   \FeatureImpl2.dll

因此,我对每个功能执行 heat.exe 来为每个功能创建一个片段,但是我得到的片段基本上是相同的,例如

So I execute heat.exe for each feature to create a fragment for each feature but I get basically identical fragments e.g.

[...] Source="SourceDir\FeatureImpl.dll"
[...] Source="SourceDir\FeatureImpl2.dll"

我真正想要的是这样的东西:

What I really want is something like this:

[...] Source="SourceDir\FeatureA\FeatureImpl.dll"
[...] Source="SourceDir\FeatureA\FeatureImpl2.dll"

[...] Source="SourceDir\FeatureB\FeatureImpl.dll"
[...] Source="SourceDir\FeatureB\FeatureImpl2.dll"

我可以使用 -var 来指定一个单独的变量来表示每个功能的源位置,但是随后我必须将这些变量的值传递到wixproj中(我将具有约10个功能).

I could use -var to specify a separate variable to represent the source location for each feature, but then I'd have to pass values for these variables into the wixproj (and I'm going to have ~10 features).

那么,有什么办法可以在收获的片段中包含相对路径?

So, is there any way I can include a relative path in my harvested fragment?

推荐答案

您可以在DefineConstants中的.wixproj中分配源路径,也可以在WIX​​包含文件中分配源路径,但是无论哪种方式,您都必须使用"var"选项以指定用于您的来源的变量.

You can either assign your source paths in .wixproj in DefineConstants or you can assign them in a WIX include file but either way you will have to use "var" option to specify the variable being used for your sources.

如果要在wixproj中使用DefineConstant,则必须执行类似的操作

If you want to use DefineConstant in wixproj then you will have to do something like

        <Target Name="BeforeBuild">
            <PropertyGroup>
              <DefineConstants>BINFOLDER=..\PATH\TO\SOURCE\$(Configuration)</DefineConstants>
            </PropertyGroup>    
            <HeatDirectory OutputFile="output.wxs" Directory="..\PATH\TO\SOURCE\$(Configuration)" DirectoryRefId="INSTALLFOLDER" ComponentGroupName="COMPONENTGROUPNAME" ToolPath="$(WixToolPath)" PreprocessorVariable="var.BINFOLDER" />    
        </Target>

在Heat任务中,请确保您添加了可能需要的所有其他属性.如果您在.wixproj中添加了对源项目的引用,则可以直接使用 "PreprocessorVariable"属性中的项目参考变量.例如,使用var.MyProject.TargetDir代替var.BINFOLDER.

In Heat task make sure you add any additional attributes that you might need. In case you have added a reference to your source project in the .wixproj then you may directly use the project reference variables in the "PreprocessorVariable" attribute. For example instead of var.BINFOLDER use var.MyProject.TargetDir.

如果要使用WIX包含文件(.wxi),请在包含文件中声明变量,例如Variables.wxi:

If you want to use a WIX include file (.wxi) then declare your variables in an include file for example Variables.wxi:

        <?xml version="1.0" encoding="UTF-8"?>
        <Include>
          <?define PATH1="PATH\TO\SOURCE"?>
          <?define PATH2="$(var.PATH1)\$(Configuration)"?>
        </Include>

现在,您将需要在heat命令行中使用-var传递PATH1和PATH2.拥有.wxs文件后,您将需要使用

Now you will need to pass in PATH1 and PATH2 using the -var in the heat command line. Once you have your .wxs file you will then need to include the Variables.wxi file in that using

<?include Variables.wxi ?>

在您的.wxs中.这种方式的问题是,每次生成WIX源文件时,您将不得不手动添加这个include指令,或者必须使用XSL Transformation注入它.

in your .wxs. The problem with this way is that you will have to either add this include directive manually each time you generate your WIX source files or you will have to inject it using XSL Transformation.

这篇关于在WiX中收集多个目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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