We have three types/flavours of our product, but only one MSI written in WiX. When we build the installer we pass in the flavour via a defined constant:
Call MSBUILD.bat ..MSIsCoreProductOurProduct.sln /p:DefineConstants="FLAVOUR=%_Flavour%"
and the constant is setup in Visual Studio, under Build -> Define preprocessor variables as FLAVOUR=50. The build process, passes in values 50, 200 or LITE as the flavour.
In the WiX code we have loads of conditions on our components that tell it which file to install based on the flavour; eg
<Component Id="cmp7F45920B1AA100729BAE37FC846B3FC5" Guid="*">
<File Id="fil238A776D9294E14671E012472F9F7196"
KeyPath="yes"
Source="$(var.MenusPath)ClientListView 200.r5m"
<Condition>$(var.FLAVOUR)=200</Condition>
</Component>
<Component Id="cmp8BFF42B232724DC4BA5B8F87994DEF21" Guid="*">
<File Id="fil808D6428D67248DDB8CA65DBC5978283"
KeyPath="yes"
Source="$(var.MenusPath)ClientListView Lite.r5m"
<Condition>$(var.FLAVOUR)=LITE</Condition>
</Component>
So the example above will install a file called "ClientListView Lite.r5m" if the FLAVOUR is LITE or it will install a file called "ClientListView 200.r5m" if the FLAVOUR is 200.
This all works as expected and has done for years !!
But now, we have a web version of our product and we need a zip file to contain the folder structure and files that would be installed for each flavour. I discovered that you can run a msi at the command line using MSIEXEC and the /a argument which will then redirect everything that would have been installed into a folder & thought this is exactly what I want ... but alas it's not working as I'd expected.
What it seems to be doing is running the MSI and extracting the files into the target folder, but it is ignoring the flavour and so you end up with both the "ClientListView Lite.r5m" and "ClientListView 200.r5m" files been extracted into the folder; which is obviously not what I want.
Upon reading the docs on MSIEXEC, it seems that you can pass in the value for a Public property eg msiexec.exe /a "C:Example.msi" MY_PROP="myValue" - so I thought this might help me; so in my WiX code I added the line:
<Property Id='PRODTYPE' Value="$(var.FLAVOUR)"/>
and then altered my component conditions to be like:
<Component Id="cmp7F45920B1AA100729BAE37FC846B3FC5" Guid="*">
<File Id="fil238A776D9294E14671E012472F9F7196"
KeyPath="yes"
Source="$(var.MenusPath)ClientListView 200.r5m"
<Condition><![CDATA[PRODTYPE=200]]></Condition>
</Component>
<Component Id="cmp8BFF42B232724DC4BA5B8F87994DEF21" Guid="*">
<File Id="fil808D6428D67248DDB8CA65DBC5978283"
KeyPath="yes"
Source="$(var.MenusPath)ClientListView Lite.r5m"
<Condition><![CDATA[PRODTYPE=LITE]]></Condition>
</Component>
but although that compiled ok, running it via:
msiexec /a OurProduct.msi /qb PRODTYPE=200 TARGETDIR="C:InstalledFiles200"
still extracts both files for the 200 & LITE flavours, where I just wanted the one for 200.
So, am I trying to do something that is not possible ... or am I doing something wrong - any help would be gratefully appreciated, because the alternative of mimicking the process in a batch file to create my zip; will be horrendous !!
Cheers,
Chris.
Question&Answers:
os