I'm trying to build an installer using WiX. My software provides updates for different versions (V23
, V22
, V21
, and so on). I'm using Heat to generate the list of required libraries (including my own) dynamically.
I'd like my Installer to:
The easiest way I could think of doing this would be to have three different harvest paths, one for each heat generated list of DLLs. However, wix/heat doesn't allow me to name the harvestpath anything other than HarvestPath
, so the following doesn't work. It still highlights what I want to achieve, which is why I'm posting it here nonetheless.
How would I achieve what I'm trying to do here?
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>HarvestPath23=..\MySoftware\bin\REL23\</DefineConstants>
<DefineConstants>HarvestPath22=..\MySoftware\bin\REL22\</DefineConstants>
<DefineConstants>HarvestPath21=..\MySoftware\bin\REL21\</DefineConstants>
<Cultures>en-US</Cultures>
</PropertyGroup>
<ItemGroup>
<Compile Include="Product.wxs"/>
<!-- This is the Heat created one for 23 -->
<Compile Include="HeatGeneratedFileList23.wxs"/>
<!-- This is the Heat created one for 22 -->
<Compile Include="HeatGeneratedFileList22.wxs"/>
<!-- This is the Heat created one for 21 -->
<Compile Include="HeatGeneratedFileList21.wxs"/>
</ItemGroup>
<Target Name="BeforeBuild">
<HeatDirectory Directory="..\MySoftware\bin\REL23\" PreprocessorVariable="var.HarvestPath23" OutputFile="HeatGeneratedFileList23.wxs" ComponentGroupName="HeatGenerated23" RunAsSeparateProcess="$(RunWixToolsOutOfProc)" DirectoryRefId="INSTALLFOLDER23" AutogenerateGuids="true" ToolPath="$(WixToolPath)" SuppressFragments="true" SuppressRegistry="true" SuppressRootDirectory="true"/>
<HeatDirectory Directory="..\MySoftware\bin\REL22\" PreprocessorVariable="var.HarvestPath22" OutputFile="HeatGeneratedFileList22.wxs" ComponentGroupName="HeatGenerated22" RunAsSeparateProcess="$(RunWixToolsOutOfProc)" DirectoryRefId="INSTALLFOLDER22" AutogenerateGuids="true" ToolPath="$(WixToolPath)" SuppressFragments="true" SuppressRegistry="true" SuppressRootDirectory="true"/>
<HeatDirectory Directory="..\MySoftware\bin\REL21\" PreprocessorVariable="var.HarvestPath21" OutputFile="HeatGeneratedFileList21.wxs" ComponentGroupName="HeatGenerated21" RunAsSeparateProcess="$(RunWixToolsOutOfProc)" DirectoryRefId="INSTALLFOLDER21" AutogenerateGuids="true" ToolPath="$(WixToolPath)" SuppressFragments="true" SuppressRegistry="true" SuppressRootDirectory="true"/>
</Target>
<Feature Id="ProductFeature23" Title="My super software 2023" Level="1"
ConfigurableDirectory="INSTALLFOLDER23">
<ComponentGroupRef Id="HeatGenerated23"/>
<ComponentGroupRef Id="ProductContents"/>
</Feature>
<Feature Id="ProductFeature22" Title="My super software 2022" Level="1"
ConfigurableDirectory="INSTALLFOLDER22">
<ComponentGroupRef Id="HeatGenerated22"/>
</Feature>
<Feature Id="ProductFeature21" Title="My super software 2021" Level="1"
ConfigurableDirectory="INSTALLFOLDER21">
<ComponentGroupRef Id="HeatGenerated21"/>
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="CommonAppDataFolder" Name="MyAppDataFolder">
<Directory Id="DIR_FOO" Name="FOO">
<Directory Id="DIR_Contents" Name="Contents">
<Directory Id="INSTALLFOLDER23" Name="2023"/>
<Directory Id="INSTALLFOLDER22" Name="2022"/>
<Directory Id="INSTALLFOLDER21" Name="2021"/>
</Directory>
</Directory>
</Directory>
</Directory>
</Fragment>
Ok I actually managed to do exactly what I wanted by just defining all three HarvestPaths
in one DefineConstants
context instead of three separate ones.
So in the code sample above, instead of this:
<DefineConstants>HarvestPath23=..\MySoftware\bin\REL23\</DefineConstants>
<DefineConstants>HarvestPath22=..\MySoftware\bin\REL22\</DefineConstants>
<DefineConstants>HarvestPath21=..\MySoftware\bin\REL21\</DefineConstants>
use this
<DefineConstants>HarvestPath23=..\MySoftware\bin\REL23\;HarvestPath22=..\MySoftware\bin\REL22\;HarvestPath21=..\MySoftware\bin\REL21\</DefineConstants>
and all the rest works fine!