Chris
Chris

Reputation: 3

WIX v4 Unable to reference action state of a feature in the custom element property condition

When trying to add a custom action condition to the Install Execute Sequence of that action. The build will fail when the action state of a feature is referenced via the '&'.

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
  <Package Name="New App" Manufacturer="Coder" Version="1.0.0.0" Scope="perMachine" UpgradeCode="56858172-dbce-452f-855c-2c24cc44a192">
    <MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" />
    <MediaTemplate EmbedCab="true"/>
    
    <Property Id="POWERSHELL" Value="powershell.exe"/>
    <CustomAction Id="PsInstallSkdTasks" Property="POWERSHELL" Return="asyncNoWait" ExeCommand="-File &quot;[INSTALLFOLDER]\InstallScheduledTasks.ps1&quot;" />
    <InstallExecuteSequence>
      <Custom Action="PsInstallSkdTasks" OnExit="success" Condition="(?CompPsIns = 3) AND ((!Main = 3) OR (&Main = 3))" />
    </InstallExecuteSequence>
    
    <Feature Id="Main" Level="1" AllowAdvertise="false" Display="expand" Title="Main App" Description="Descr...">
      <ComponentGroupRef Id="CompGrpMain" />
    </Feature>
  </Package>
</Wix>

When I attempt to build this I get the following error: error WIX0104: Not a valid source file; detail: ' ' is an unexpected token. The expected token is ';'.

But then '&Main;' is not a defined entity.

I believe it wants a semicolon after &Main in the condition because the condition has been moved to a property and I believe the XML parser is expecting it. So I'm not sure if this is a bug in version 4 or if there is meant to be a new notation to match this functionality that is documented here:

FireGiant Expression Syntax

I've been unable to find any documentation of the implementation of the condition property for version 4 of the Wixtoolset, as the existing documentation provides no explanations at this time.

Wixtoolset Custom Element

Upvotes: 0

Views: 297

Answers (1)

Bob Arnson
Bob Arnson

Reputation: 21896

You can't use a naked & in XML. Use &amp; instead.

Upvotes: 0

Related Questions