Custom actions on Install OR Major Upgrade

2

I have a Wix installer for some TopShelf services I'm deploying. How do I configure a complete uninstall & re-install during a major upgrade?

Currently I have a consistent UPGRADECODE, an incrementing VERSION and this:

<MajorUpgrade AllowSameVersionUpgrades="yes" DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit." />

<InstallExecuteSequence>

  <!-- always run configure/install/start after installation OR after upgrading -->
  <Custom Action="ConfigureFor" Before="InstallFinalize">(NOT INSTALLED OR UPGRADINGPRODUCTCODE)</Custom>
  <Custom Action="InstallExporter" After="ConfigureFor">(NOT INSTALLED OR UPGRADINGPRODUCTCODE)</Custom>
  <Custom Action="StartExporter" After="InstallExporter">(NOT INSTALLED OR UPGRADINGPRODUCTCODE)</Custom>
  <Custom Action="InstallScheduler" After="ConfigureFor">(NOT INSTALLED OR UPGRADINGPRODUCTCODE)</Custom>
  <Custom Action="StartScheduler" After="InstallScheduler">(NOT INSTALLED OR UPGRADINGPRODUCTCODE)</Custom>

  <!-- always run stop/uninstall before uninstallation OR before upgrading -->
  <Custom Action="StopExporter" Before="UninstallExporter">(INSTALLED OR UPGRADINGPRODUCTCODE)</Custom>
  <Custom Action="StopScheduler" Before="UninstallScheduler">(INSTALLED OR UPGRADINGPRODUCTCODE)</Custom>
  <Custom Action="UninstallExporter" After="InstallInitialize">(INSTALLED OR UPGRADINGPRODUCTCODE)</Custom>
  <Custom Action="UninstallScheduler" After="InstallInitialize">(INSTALLED OR UPGRADINGPRODUCTCODE)</Custom>

</InstallExecuteSequence>

The problem seems to be that the custom action ConfigureFor, is being called during the uninstallation part of a major upgrade...

Action start 17:36:08: INSTALL.
Action start 17:36:08: FindRelatedProducts.
Action ended 17:36:08: FindRelatedProducts. Return value 0.
Action start 17:36:08: AppSearch.
Action ended 17:36:08: AppSearch. Return value 1.
Action start 17:36:08: LaunchConditions.
Action ended 17:36:08: LaunchConditions. Return value 1.
Action start 17:36:08: ValidateProductID.
Action ended 17:36:08: ValidateProductID. Return value 1.
Action start 17:36:08: CostInitialize.
Action ended 17:36:08: CostInitialize. Return value 1.
Action start 17:36:08: FileCost.
Action ended 17:36:08: FileCost. Return value 1.
Action start 17:36:08: CostFinalize.
Action ended 17:36:08: CostFinalize. Return value 1.
Action start 17:36:08: MigrateFeatureStates.
Action ended 17:36:08: MigrateFeatureStates. Return value 0.
Action start 17:36:08: InstallValidate.
Action ended 17:36:22: InstallValidate. Return value 1.
Action start 17:36:22: RemoveExistingProducts.
Action ended 17:36:22: RemoveExistingProducts. Return value 0.
Action start 17:36:22: InstallInitialize.
Action ended 17:36:22: InstallInitialize. Return value 1.
Action start 17:36:22: SetUninstallExporter.
Action ended 17:36:22: SetUninstallExporter. Return value 1.
Action start 17:36:22: SetStopExporter.
Action ended 17:36:22: SetStopExporter. Return value 1.
Action start 17:36:22: SetUninstallScheduler.
Action ended 17:36:22: SetUninstallScheduler. Return value 1.
Action start 17:36:22: SetStopScheduler.
Action ended 17:36:22: SetStopScheduler. Return value 1.
Action start 17:36:22: ProcessComponents.
Action ended 17:36:22: ProcessComponents. Return value 1.
Action start 17:36:22: UnpublishFeatures.
Action ended 17:36:22: UnpublishFeatures. Return value 1.
Action start 17:36:22: RemoveRegistryValues.
Action ended 17:36:22: RemoveRegistryValues. Return value 1.
Action start 17:36:22: RemoveFiles.
Action ended 17:36:22: RemoveFiles. Return value 1.
Action start 17:36:22: InstallFiles.
Action ended 17:36:22: InstallFiles. Return value 1.
Action start 17:36:22: WriteRegistryValues.
Action ended 17:36:22: WriteRegistryValues. Return value 1.
Action start 17:36:22: RegisterUser.
Action ended 17:36:22: RegisterUser. Return value 0.
Action start 17:36:22: RegisterProduct.
Action ended 17:36:22: RegisterProduct. Return value 1.
Action start 17:36:22: PublishFeatures.
Action ended 17:36:22: PublishFeatures. Return value 1.
Action start 17:36:22: PublishProduct.
Action ended 17:36:22: PublishProduct. Return value 1.
Action start 17:36:22: SetConfigureFor.
Action ended 17:36:22: SetConfigureFor. Return value 1.
Action start 17:36:22: ConfigureFor.
Action ended 17:36:22: ConfigureFor. Return value 1.
Action start 17:36:22: SetInstallExporter.
Action ended 17:36:22: SetInstallExporter. Return value 1.
Action start 17:36:22: InstallExporter.
Action ended 17:36:22: InstallExporter. Return value 1.
Action start 17:36:22: SetStartExporter.
Action ended 17:36:22: SetStartExporter. Return value 1.
Action start 17:36:22: StartExporter.
Action ended 17:36:22: StartExporter. Return value 1.
Action start 17:36:22: SetInstallScheduler.
Action ended 17:36:22: SetInstallScheduler. Return value 1.
Action start 17:36:22: InstallScheduler.
Action ended 17:36:22: InstallScheduler. Return value 1.
Action start 17:36:22: SetStartScheduler.
Action ended 17:36:22: SetStartScheduler. Return value 1.
Action start 17:36:22: StartScheduler.
Action ended 17:36:22: StartScheduler. Return value 1.
Action start 17:36:22: InstallFinalize.
CAQuietExec:  The term 'c:\Program Files (x86)\Sunshine\configureFor.ps1' is not recognized a
CAQuietExec:  s the name of a cmdlet, function, script file, or operable program. Check the s
CAQuietExec:  pelling of the name, or if a path was included, verify that the path is correct
CAQuietExec:   and try again.
CAQuietExec:  At line:1 char:2
CAQuietExec:  + & <<<<  'c:\Program Files (x86)\Sunshine\configureFor.ps1' -environment   > '
CAQuietExec:  c:\Program Files (x86)\Sunshine\configureFor.log.txt'
CAQuietExec:      + CategoryInfo          : ObjectNotFound: (c:\Program File...onfigureFor.p 
CAQuietExec:     s1:String) , CommandNotFoundException
CAQuietExec:      + FullyQualifiedErrorId : CommandNotFoundException
CAQuietExec:   
CAQuietExec:  Error 0x80070001: Command line returned an error.
CAQuietExec:  Error 0x80070001: CAQuietExec Failed
CustomAction ConfigureFor returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
Action ended 17:36:25: InstallFinalize. Return value 3.
Action ended 17:36:26: INSTALL. Return value 3.

I've updated my configuration above. this is what I'm currently using. Basically, what we need to happen is:

  • always run configure/install/start after installation OR after upgrading
  • always run stop/uninstall before uninstallation OR before upgrading

Upon further testing. It appears like ConfigureFor is run all the time, even during the "RemovePreviousProducts" phase - Why isn't it respecting my conditions?

wix
wix3.5
asked on Stack Overflow Nov 15, 2012 by mwjackson • edited Jul 6, 2017 by BartoszKP

2 Answers

1

Try using adding AND OR UPGRADINGPRODUCTCODE making your code look like:

<Custom Action="ConfigureFor" Before="InstallFinalize">(NOT INSTALLED OR NOT UPGRADINGPRODUCTCODE)</Custom>

You can find more properties that are set by the Windows installer that you could use here.

answered on Stack Overflow Nov 16, 2012 by Zak Soliman • edited Nov 19, 2012 by Zak Soliman
1

How about this:

<InstallExecuteSequence>

  <!-- always run configure/install/start after installation OR after upgrading -->
  <Custom Action="ConfigureFor" Before="InstallFinalize">NOT (REMOVE ~= "ALL")</Custom>
  <Custom Action="InstallExporter" After="ConfigureFor">NOT (REMOVE ~= "ALL"))</Custom>
  <Custom Action="StartExporter" After="InstallExporter">NOT (REMOVE ~= "ALL")</Custom>
  <Custom Action="InstallScheduler" After="ConfigureFor">NOT (REMOVE ~= "ALL")</Custom>
  <Custom Action="StartScheduler" After="InstallScheduler">NOT (REMOVE ~= "ALL")</Custom>

  <!-- always run stop/uninstall before uninstallation OR before upgrading -->
  <Custom Action="StopExporter" Before="UninstallExporter">REMOVE ~= "ALL"</Custom>
  <Custom Action="StopScheduler" Before="UninstallScheduler">REMOVE ~= "ALL"</Custom>
  <Custom Action="UninstallExporter" After="InstallInitialize">REMOVE ~= "ALL"</Custom>
  <Custom Action="UninstallScheduler" After="InstallInitialize">REMOVE ~= "ALL"</Custom>

</InstallExecuteSequence>

Also, this SO post may help you: How to add a WiX custom action that happens only on uninstall (via MSI)?

answered on Stack Overflow Nov 20, 2012 by BryanJ • edited May 23, 2017 by Community

User contributions licensed under CC BY-SA 3.0