3
votes

I want to include different dll in the installation based on certain values. So, I am trying to load a component based on a property that is set using custom action.

In wxs file:

...
<Property Id="PropDllVersion" Value="0" />
...
<CustomAction Id="CheckPropDllVersion" BinaryKey="CustomAction1.dll" DllEntry="GetPropVersion" Return="ignore" Execute="immediate"/>
...
<InstallExecuteSequence>
    <Custom Action="CheckPropDllVersion" After="ValidateProductID" />      
</InstallExecuteSequence>
...
  <Component Id="Test"
     Guid="B81F832D-2D96-4169-9BD0-8D77098FEC60">
    <Condition><![CDATA[PropDllVersion = "19"]]></Condition>
    <File Id="File15"
      Name="xyz.dll"
      Vital="yes"
      KeyPath="yes"
      AssemblyManifest="File5"
      AssemblyApplication="File5"
      Assembly=".net"
      DiskId="1" 
      />
  </Component>
...

Then in the custom action file:

[CustomAction]
        public static ActionResult GetPropVersion(Session session)
        {
    session["PropDllVersion"] = "19";
        }

I can see in the msi log file that this property is changed to 19, however the xyz.dll is not included in the installation. It looks like the PropDllVersion is not set at the condition level or am I doing something wrong... I tried to sequence it at many other places still it is not working...

If I use a global property in the condition instead of my property it works!

2
Not sure why I got a negative rating for this question. Not that I have not tried all the other solutions presented here. Would appreciate the reason for the negative rating to this question... - Samuel

2 Answers

3
votes

Please note that private properties (its name contains lowercase letters) use their default values in InstallExecuteSequence. So you should use a public property, for example PROP_DLL_VERSION.

2
votes

Where else have you tried to sequence your custom action? You need to sequence it before the CostInitialize action.

Also, call the FileCost action following CostInitialize and the CostFinalize action then.

You can check out the documentation of the CostInitialize action here: http://msdn.microsoft.com/en-us/library/windows/desktop/aa368050%28v=vs.85%29.aspx