Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conditionally install files based on Command Line Argument during WIX Install

I am wanting to install files during a wix install conditionally whether a command line parameter has been set

e.g. I have the following file, which only installs if a DEBUG flag has been set

    <Component Id="file.pdb" Guid="SOME-GUID">
       <Condition>DEBUG</Condition>
       <File Id="file.pdb" Source="file.pdb" KeyPath="yes" Vital="no" />
    </Component>

I have added the DEBUG property and read it in from the command line. The File never installs though, I am perplexed as to why?

like image 347
pengibot Avatar asked Oct 20 '25 17:10

pengibot


1 Answers

Solved the issue. Below is an explanation of what I was doing wrong and what I did to solve it

I had created an installer (.msi) and was using the following cmd line args to start it up

msiexec -i prog.msi DEBUGPROPERTY=True

I had several merge modules with components which would install depending on whether this property was set which were getting the property injected into them like so...

<Merge
    Id="SomeID"
    Language="1033"
    SourceFile="Module.msm"
    DiskId="1">
    <ConfigurationData
      Name="debugProperty"
      Value="[DEBUGPROPERTY]" />

What I was missing was in the merge modules (.msm) i needed the following code

    <Configuration Name='debugProperty' Format='Text' DefaultValue='[DEBUGPROPERTY]'/>
    <Substitution Table='CustomAction' Row='setDebugProperty' Column='Target' Value='[=debugProperty]'/>
    <CustomAction Id='setDebugProperty' Property='DEBUGPROPERTY' Value='[DEBUGPROPERTY]'/>

    <InstallExecuteSequence>
            <Custom Action='setDebugProperty' Before="LaunchConditions">1</Custom>
    </InstallExecuteSequence>

This allowed me to access the property DEBUGPROPERTY inside this module so i could restrict whether a file was installed at install time or not, like so

<Component Id="File.pdb" Guid="SOME-GUID">
    <Condition>DEBUGPROPERTY</Condition>
    <File Id="File.pdb" Source="File.pdb" KeyPath="yes" Vital="no" />
</Component>

This now works, and allows me to install .pdb files during an install if i include this argument.

like image 155
pengibot Avatar answered Oct 23 '25 08:10

pengibot