"Not" Installed Check operators don't seem to work

Mar 17, 2010 at 2:13 PM
Edited Mar 17, 2010 at 2:14 PM

Hi,

I'm trying to get a couple of MSI components in my bootstrapper to only be (optionally) allowed for installation if a pre-requisite exists.

I've stripped my code down to the basic stuff to check for only one pre-requisite & a "Not" Installed Check Operator. With or without the "Not" the behaviour is exactly the same, if the pre-req is installed my component isn't available for installation, if the pre-req isn't installed my component is available (this is the inverse of what I want to achieve).

My Installed Checks are as follows:

<

installedcheck id="34dd7c71-633f-446a-b48b-e1fe13b696f3" id_type="upgradecode" propertyname="VersionString" propertyvalue="1.0.0.0" comparison="exists" defaultvalue="False" type="check_product" description="Installed Check" />

 <installedcheckoperator type="Not" description="Installed Check Operator" />

I've tried putting the Installed Check Operator before & after the Installed Check ID in the XML but standard XML practices mean it shouldn't make a difference what the order is since they're both child Elements of the component element. Regardless of the ordering, the behaviour is the same as described above.

The concept of installed check operators seems a bit nebulous at present. Without any of them the default behaviour when you have more than one installed check defined is an "Or" type of logic which is what one would expect so the "Or" type seems redundant. The "Not" operator seems to suggest it should inverse all installed checks under the component which for my purposes in this instance would be fine but I can envisage a situation where I'd want to "Not" one of the installed checks but keep the other as is. It would make more complex configuration models easier if operators were children of installed checks but I don't know how you'd make the "And" work properly in that setup unless you also made installed checks children of operators (which would also allow easy implementation of NAND/ XOR operators).

The pre-req I'm testing for above is an installation of Google SketchUp 7 as my MSI component is a plug-in which works with both SketchUp 6 and 7 so in the final solution I'll have 2 of those under this component to check for the 2 different versions upgrade codes (they allow you to have SU6 & SU7 concurrently installed). I've also got another plug-in to create a component for which needs to detect the 2008, 2009 & 2010 releases of Autodesk Revit Architecture & Autodesk Revit MEP (both x86 & x64 versions of those apps so 10 different apps at present increasing to 14 in April when the 2011 versions are released hence I'm working on getting the SketchUp plug-in working first since it's easier by at least a factor of 5).

I'm using the currently released 1.9 build (4817). Let me know if I should create a ticket in the issue tracker for this.

Mar 17, 2010 at 3:45 PM
Edited Mar 17, 2010 at 3:47 PM

Been thinking about the implementation of the installcheckoperator over lunch.

Current system works as an "Or" operator. You can specify any number of checks & if one of them returns false your component is scheduled e.g.

<component>

  <installedcheck 1 />

  <installedcheck 2 />

  ...

  <installedcheck x />

</component>

This doesn't require an installedcheckoperator declared, it works as an "Or" operator simply by declaring more than one installed check.

 

Implementing the "Not" operator should be as easy as putting a new attribute on the installed check types which inverts the value it returns. Something like invert="yes/no" would work fine e.g.

<component>

  <installedcheck 1 invert="no" /> same as current behaviour (schedules an installation if the check returns false)

</component>

<component>

  <installedcheck 2 invert="yes" /> this would schedule an installation only if the check returns true (invert makes it return false)

</component>

 

The "And" operator is a bit more tricky but one simple & elegant solution would be to enable installedchecks to be children of themselves. This could be further streamlined by only evaluating child elements if the parent returns false e.g.

<component>

  <installedcheck 1>

    <installedcheck 2> only evaluated if 1 returns false.

      <installedcheck 3 /> only evaluated if 2 returns false.

    </installedcheck>

  </installedcheck>

</component>

Essentially the above would allow dropping the installedcheckoperator altogether, replacing it with functionality which is much easier to intuit. This also has the additional benefit that combining any of the above would allow for very powerful and specific logic to be created by users with very simple code.

Again let me know if you would like me to create an issue tracker ticket for this or whether I'm on the wrong track altogether.

Coordinator
Mar 18, 2010 at 1:06 PM
Edited Mar 18, 2010 at 1:06 PM

I gave this some thought. Maybe we don't want to change everything introducing an operator switch that's hard to see in all operators. But maybe Not can be extended to either have an And or an Or behavior as a new option (to become Not And or Not Or)?

Update: Btw, can you achieve what you want to day with nesting an And under a Not?

Mar 18, 2010 at 3:50 PM

OK disregard everything above. Apparently I had no idea how to use the installedcheckoperators. I didn't know that they are supposed to have checks nested under them as children Elements. In my defence the documentation is rather sparse on the subject. It's pretty obvious now I know how they're meant to be used but I honestly didn't have the slightest idea that anything in the checks menu could be nested.

I currently have the following working as intended for just version 7 of SketchUp.

<installedcheckoperator type="And" description="Installed Check Operator">

  <installedcheck id="my-upgrade-guid" id_type="upgradecode" propertyname="VersionString" propertyvalue="2.0.5" comparison="version" defaultvalue="True" type="check_product" description="Installed Check" />

  <installedcheckoperator type="Not" description="Installed Check Operator">

    <installedcheck id="34dd7c71-633f-446a-b48b-e1fe13b696f3" id_type="upgradecode" propertyname="VersionString" propertyvalue="1.0.0.0" comparison="exists" defaultvalue="False" type="check_product" description="Installed Check" />

  </installedcheckoperator>

</installedcheckoperator>

This checks for the existence of SketchUp 7 & allows installation of my component if it exists, disables it if SketchUp 7 doesn't exist. It also checks if my component already exists at version 2.0.5 & disallows installation in that case (the defaultvalue=true is very useful here).

Now to make it ridiculously complex (fun times).

Thanks for the help & as I said earlier, ignore all my earlier suggestions (may want to expand the section in the documentation on installedcheckoperators so other people don't make the same dumb mistake I did though).

Coordinator
Mar 19, 2010 at 3:23 PM

I've changed the documentation like this:

Check Operators

You can combine results from multiple elements by nesting one or more InstalledCheck elements under an InstalledCheckOperator. You may nest operators under other operators. The following operators are supported: And, Or and Not.

 

Remember that the check tests whether the component is installed and a component appears in the boostrapper at setup time only if it is not installed. When combining component operators this behavior may require some mental gymnastics.

User-defined controls are the opposite. A control will be enabled or visible if the installed check evaluates to True.

 

By default the Not operator behaves as Not Or. When multiple installed checks are nested under this operator, if any of the checks returns true, the Not operator will return False. To achieve a Not And behavior, nest an And operator under a Not operator.