Reputation: 1
I created an msi for an application that relies on a deferred custom action to do a few necessary things.
<CustomAction Id="MyCustomAction" Directory="INSTALLFOLDER" Execute="deferred" Impersonate="no" ExeCommand="script "[INPUTFOLDER]" Return="check">
Doing something
</CustomAction>
This custom action is supposed to run when the program is not installed or being upgraded. During installation, it goes well and does what it needs to do. However, during upgrade, it just breaks.
<InstallExecuteSequence>
<RemoveExistingProducts Before="InstallInitialize" />
<Custom Action="MyCustomAction" Before="InstallFinalize">
<![CDATA[NOT Installed OR UPGRADINGPRODUCTCODE]]>
</Custom>
</InstallExecuteSequence>
As for the upgrade, I expect the old folder containing the previous installation to be removed and that everything gets installed in the new one (another name, since the version of the program is part of it - currently changing from 0.1.0 to 0.1.1).
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="INSTALLFOLDER" Name="My Application 0.1.1">
<Component Id='MainExecutable' Guid='something' Win64='yes'>
<RemoveFolder Id='ProgramFiles64Folder' On='uninstall' />
<Environment Id="PATH" Name="PATH" Value="[INSTALLFOLDER]something" Permanent="no" Part="last" Action="set" System="yes" />
<RegistryKey Id='MyInstallDir' Root='HKLM' Key='somekey' ForceCreateOnInstall='yes' ForceDeleteOnUninstall='yes' >
<RegistryValue Type='string' Name='InstallDir' Value='[INSTALLFOLDER]' Action='write' />
</RegistryKey>
</Component>
</Directory>
</Directory>
</Directory>
I ran some tests with the upgrade and my custom action is running before the new folder is actually created. Since I need some files that are moved/copied into the target dir during installation to run the custom action, I thought that the crash happened due to referencing a file that doesn't exist yet. However, if I change my custom action to something that just starts the notepad or any other known app/service, for instance, it breaks anyway. It seems that having this custom action, no matter what it is, breaks the upgrade.
I tried using
<MajorUpgrade AllowSameVersionUpgrades="yes" DowngradeErrorMessage="A newer version of [ProductName] is already installed. If you are sure you want to downgrade, remove the existing installation via Programs and Features." />
later added a new step to the install sequence
<InstallExecuteSequence>
<RemoveExistingProducts Before="InstallInitialize" />
<Custom Action="CallInstaller" Before="InstallFinalize">
<![CDATA[NOT Installed OR UPGRADINGPRODUCTCODE]]>
</Custom>
</InstallExecuteSequence>
and finally
<Property Id="PREVIOUSVERSIONSINSTALLED" Secure="yes" />
<Upgrade Id="some id">
<UpgradeVersion
Minimum="0.0.0.1" Maximum="99.0.0.0"
Property="PREVIOUSVERSIONSINSTALLED"
IncludeMinimum="yes" IncludeMaximum="no" />
</Upgrade>
But none of these have worked as intended. As extra information, in the new wix file I changed the version, package id, and product id.
What changes in the context of a custom action to be executed during upgrade compared to the installation step? For the upgrade I expect to have the old folder deleted, then the creation of the new folder and installation with the custom action.
Edit:
Parts of the log when installation succeeds:
MSI (s) (98:F0) [09:06:16:875]: Doing action: MyCustomAction
MSI (s) (98:F0) [09:06:16:875]: Note: 1: 2205 2: 3: ActionText
Action 09:06:16: MyCustomAction.
Action start 09:06:16: MyCustomAction.
MyCustomAction:
Action ended 09:06:16: MyCustomAction. Return value 1.
...
MSI (s) (98:F0) [09:06:17:826]: Executing op: CustomActionSchedule(Action=MyCustomAction,ActionType=3106,Source=C:\Program Files\My Program 0.1.0\,Target=C:\...\python.exe script.py "C:\a folder\,)
...
MSI (c) (B0:40) [09:09:13:009]: MainEngineThread is returning 0
Then the attempt to upgrade it to a 0.1.1 version (same custom action, same command):
MSI (s) (68:34) [12:25:38:860]: Executing op: CustomActionSchedule(Action=MyCustomAction,ActionType=3106,Source=C:\Program Files\My Program 0.1.1\,Target=C:\...\python.exe script.py "C:\a folder\,)
MSI (s) (68:34) [12:25:38:860]: Note: 1: 1721 2: MyCustomAction 3: C:\Program Files\My Program 0.1.1\ 4: C:\...\python.exe script.py "C:\a folder\
MSI (s) (68:34) [12:25:38:860]: Note: 1: 2205 2: 3: Error
MSI (s) (68:34) [12:25:38:860]: Note: 1: 2228 2: 3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 1721
Error 1721. There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor. Action: MyCustomAction, location: C:\Program Files\My Program 0.1.1\, command: C:\...\python.exe installer.py "C:\a folder\
MSI (s) (68:34) [12:25:39:728]: Note: 1: 2205 2: 3: Error
MSI (s) (68:34) [12:25:39:728]: Note: 1: 2228 2: 3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 1709
MSI (s) (68:34) [12:25:39:728]: Product: My Program -- Error 1721. There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor. Action: MyCustomAction, location: C:\Program Files\My Program 0.1.1\, command: C:\...\python.exe script.py "C:\a folder\
...
MSI (c) (B4:54) [12:25:40:802]: MainEngineThread is returning 1603
Upvotes: 0
Views: 48