In my Product.wxs file I have the following element:
<WixVariable Id="MySourceDir" Overridable="yes" Value="C:\somePath\files\"/>
then in a heat generated wxs file I have something along the lines of:
<Fragment>
<ComponentGroup Id="FunctionalLibs">
<Component Id="cmp3A42AC690DA7590004EC5796B1C6BA95" Directory="dir5DCBEA4AA069AE7BD92B4A3EA9C5EC79" Guid="{8FD7F7BF-68C1-492C-8F29-8E3003A6F441}">
<File Id="fil007BA1D3A56EDEA1D669D51D8C61F518" KeyPath="yes" Source="!(wix.MySourceDir)\file1.dll" />
</Component>
</ComponentGroup>
</Fragment>
in my nant build file I have
<light exedir="${wix.dir}"
out="${output.dir}\PluginInstaller.msi"
cultures="en-us"
rebuild="true"
suppresspdb="true">
<sources basedir="${release.dir}\obj\\${configuration}">
<include name="*.wixobj" />
</sources>
</light>
How do I set the wix.MySourceDir value from the light task?
As described in the NAnt Task Reference for Light, you can add additional arguments to Light.exe using the <arg>
tag. The command line reference for light.exe says we use -d
to define WixVariables, so:
<light exedir="${wix.dir}"
out="${output.dir}\PluginInstaller.msi"
cultures="en-us"
rebuild="true"
suppresspdb="true">
<sources basedir="${release.dir}\obj\\${configuration}">
<include name="*.wixobj" />
</sources>
<arg line="-dMySourceDir=C:\somePath\files\" />
</light>
That should do the trick. However, perhaps the simpler, more supported, and more common way of defining a source directory like you're doing is using a preprocessor variable. The Candle Task supports them directly using the <defines>
tag and the only change to your source code would be to change Source="!(wix.MySourceDir)\file1.dll"
to Source="!(var.MySourceDir)\file1.dll"
.