Collecting multiple directories in WiX

I am trying to create an installer that includes a number of functions, and I use heat to collect the file directory for each function.
My source directory structure looks something like this:

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

So, I execute heat.exe for each function to create a fragment for each function, but I get basically the same fragments, for example.

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

I really want something like this:

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

and

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

I could use -var to specify a separate variable to represent the source location for each function, but then I would have to pass the values โ€‹โ€‹of these variables to wixproj (and I'm going to have ~ 10 functions).

So, is there a way to include a relative path in my compiled fragment?

+4
source share
3 answers

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

If you want to use DefineConstant in wixproj, you will need 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> 

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

If you want to use the WIX include file (.wxi), then declare the variables in the 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> 

Now you will need to go to PATH1 and PATH2 using -var on the heat command line. Once you have your .wxs file, you will need to include the Variables.wxi file using

 <?include Variables.wxi ?> 

in your .wxs. The problem is that you will either have to add this include directive manually each time you create the WIX source files, or you will have to enter it using XSL Transformation.

0
source

Instead of using heat in each Feature* folder, you can simply collect the entire created function layout folder and convert the heat results. I assume that each subfolder is a function. This is a simple matter of creating a ComponentGroup for each of them, which refers to all the components below it.

Then you would use component groups like this:

  <Feature Id="FeatureA"> <ComponentGroupRef Id="FeatureA"/> </Feature> <Feature Id="FeatureB"> <ComponentGroupRef Id="FeatureB"/> </Feature> 

Heat command (I actually use the HarvestDirectory target in WiX 3.7):

 Heat.exe dir FeatureLayout -dr FeatureLayoutDir -srd -ag -sfrag -t FeatureLayout.xslt -out obj\Debug\__dir.wxs 

FeatureLayout.xslt:

 <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="2.0" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="wix" > <xsl:output method="xml" indent="yes"/> <xsl:template match="wix:Wix"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> <xsl:for-each select="wix:Fragment/wix:DirectoryRef/wix:Directory"> <wix:Fragment> <wix:ComponentGroup Id="{@Name}"> <xsl:for-each select="descendant::wix:Component"> <wix:ComponentRef Id="{@Id}"/> </xsl:for-each> </wix:ComponentGroup> </wix:Fragment> </xsl:for-each> </xsl:copy> </xsl:template> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet> 
+3
source

removes the properties for the installation project, this is the command I use:

 "%WIX%\bin\heat.exe" dir "$(SolutionDir)\Export\Release" -suid -dr bin -srd -cg ExportComponentGroup -var var.sourcePath -ag -sreg -out "$(SolutionDir)\SetupProject\AppExportDir.wxs" 

the only thing you need to define on the assembly tab: check the "define" debug'preprocessor variable "box and enter.

 sourcePath=%SystemDrive%\App\Main\Export\Release\ 

please make sure you use the flags you want to use as suid or -dr

for more information on the flags you see here: http://wix.sourceforge.net/manual-wix3/heat.htm

+1
source

Source: https://habr.com/ru/post/1486230/


All Articles