[wix-users] Condition to only Run Custom Actions on Initial Install

Bryan Dam bryand at recastsoftware.com
Tue Dec 21 07:52:58 PST 2021


Comments? Ain't nobody got time for dat.  Thanks for pointing them out Edwin, the helped me crack this particular nut.

I believe because I'm scheduling RemoveExistingProducts early (before the new version is installed) the Installed property is rightfully not set upon upgrade since it's been uninstalled by that time.  So in that scenario the condition for initial install is: NOT Installed AND NOT WIX_UPGRADE_DETECTED AND NOT WIX_DOWNGRADE_DETECTED AND NOT UPGRADINGPRODUCTCODE

For anyone following along it breaks down like this:
NOT Installed - Needed to avoid  final uninstall
NOT WIX_UPGRADE_DETECTED AND NOT WIX_DOWNGRADE_DETECTED - Needed to avoid upgrade/downgrade installation
NOT UPGRADINGPRODUCTCODE - Needed to avoid upgrade's uninstall


From: Edwin Castro <egcastr at gmail.com>
Sent: Monday, December 20, 2021 12:02 PM
To: Bryan Dam <bryand at recastsoftware.com>
Cc: WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org>
Subject: Re: [wix-users] Condition to only Run Custom Actions on Initial Install

Depending on whether you author your own Upgrade elements, use the MajorUpgrade element, and the version of wix toolset compared to when the Runtime.wxi was written in the post, you may need to change some of the variable names. One of the comments updates the variable names used by the MajorUpgrade element. I don't think they have changed since then but I don't remember for certain. If you author your own Upgrade elements, then you'll need to use your own property names.

--
Edwin G. Castro


On Mon, Dec 20, 2021 at 8:49 AM Bryan Dam <bryand at recastsoftware.com<mailto:bryand at recastsoftware.com>> wrote:
Thanks Edwin, I love the idea of having a standard set of properties like that across all installers.

> using appropriate property names for my version of wix toolset. The post is pretty old.
Well, that maybe is the crux of my problem; what is outdated in that post? I don't see anything in Runtime.wxi at least that stands out as no longer relevant.  Though again, maybe that's my problem; I'm not seeing it.


From: Edwin Castro <egcastr at gmail.com<mailto:egcastr at gmail.com>>
Sent: Friday, December 17, 2021 4:50 PM
To: WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org<mailto:wix-users at lists.wixtoolset.org>>
Cc: Bryan Dam <bryand at recastsoftware.com<mailto:bryand at recastsoftware.com>>
Subject: Re: [wix-users] Condition to only Run Custom Actions on Initial Install

I use the approach described here

https://code.dblock.org/2010/05/11/msi-property-patterns-upgrading-firstinstall-and-maintenance.html<https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcode.dblock.org%2F2010%2F05%2F11%2Fmsi-property-patterns-upgrading-firstinstall-and-maintenance.html&data=04%7C01%7Cbryand%40recastsoftware.com%7C971b1d7c25f34e6054a508d9c3da6819%7C9315bb44634846c6bd378880b87e774e%7C0%7C0%7C637756165093734253%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=G3%2F7OLsVyqBM9yFRdHrjpwlQcp9g3WQv7p2%2FnXLzY2g%3D&reserved=0>

using appropriate property names for my version of wix toolset. The post is pretty old.

Once you have these properties available you can just use FirstInstall in the condition which is easy to read and understand.

--
Edwin G. Castro


On Fri, Dec 17, 2021, 13:41 Bryan Dam via wix-users <wix-users at lists.wixtoolset.org<mailto:wix-users at lists.wixtoolset.org>> wrote:
I'm kinda dumbfounded to even ask this since:
A) It's been asked and answered many times (here<https://stackoverflow.com/questions/17411913/how-can-i-perform-a-custom-action-in-wix-that-only-executes-on-install-or-uninst/17425109#17425109<https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F17411913%2Fhow-can-i-perform-a-custom-action-in-wix-that-only-executes-on-install-or-uninst%2F17425109%2317425109&data=04%7C01%7Cbryand%40recastsoftware.com%7C971b1d7c25f34e6054a508d9c3da6819%7C9315bb44634846c6bd378880b87e774e%7C0%7C0%7C637756165093734253%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=HBY%2BAx7a00wck%2BitmDMFVtB7V1YW3QigW9B6kaPGxw0%3D&reserved=0>>)
B) I've done my level-headed best to memorize this property value table (here<https://stackoverflow.com/questions/320921/how-to-add-a-wix-custom-action-that-happens-only-on-uninstall-via-msi/17608049#17608049<https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F320921%2Fhow-to-add-a-wix-custom-action-that-happens-only-on-uninstall-via-msi%2F17608049%2317608049&data=04%7C01%7Cbryand%40recastsoftware.com%7C971b1d7c25f34e6054a508d9c3da6819%7C9315bb44634846c6bd378880b87e774e%7C0%7C0%7C637756165093744248%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=cXKkYoFoP7F%2ByDG8i4zz0Nv1DFAojuurriaUnw62g%2Fg%3D&reserved=0>>)
C) I've done exactly this several times in other installers

And yet, here I am. I'm creating a new installer and verifying the major upgrade process before initial release.  There's some configuration steps that gets info from the user and then saves it to a configuration file via custom action.  We only want to run that action upon initial install and skip those actions upon upgrades (including RemoveExistingProducts) and full uninstall.  Otherwise the installer properties are empty (because that bit of the UI didn't run) and the config gets wiped.

In the past I have used both of these successfully:
(NOT Installed) AND (NOT UPGRADINGPRODUCTCODE)
(NOT Installed) AND (NOT REMOVE)

I've tried every possible permutation of parenthesis there without success.  Each time the initial install works fine but upon upgrade it always runs them anyways.  I can post the full log if someone wants to see it but during the major upgrade it's skipping the actions upon install but running them during the uninstall triggered by RemoveExistingProducts.  I've tried changing the schedule from the default to afterInistallInitialize but that doesn't change the behavior.

Here's the segment as it sits now:
<Custom Action="ApplyAppConfigurationParameters" After="GenerateSelfSignedCertificate">(NOT Installed) AND (NOT UPGRADINGPRODUCTCODE)</Custom>
<Custom Action="ApplyAppConfiguration" After="ApplyAppConfigurationParameters">(NOT Installed) AND (NOT UPGRADINGPRODUCTCODE)</Custom>

Anyone got any ideas? This makes no sense to me after 8 hours of plugging away at it.

  Thanks,
     Bryan

____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/<https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.firegiant.com%2F&data=04%7C01%7Cbryand%40recastsoftware.com%7C971b1d7c25f34e6054a508d9c3da6819%7C9315bb44634846c6bd378880b87e774e%7C0%7C0%7C637756165093754248%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=tDDmnHrkIdFKFWjbc0Wtqpl07dTpKvkJYgtTJyYqBI8%3D&reserved=0>



More information about the wix-users mailing list