cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Merima
Level 3

Custom Action sequencing for rollback

I am running a managed dll that performs many database tasks on a sql server system. I have gotten the sequence correct for my InstallSqlDb and UninstallSqlDb sequences. They both run.

I have a 3rd function called RollbackSqlDb which performs different steps. I want this to occur during Rollback. Where should it be placed?

Where should it go in User Interface?
Where should it go in Execute?
Is there a condition that is needed?

I've made sure the function works right because it has a Messagebox and I've ran it as a Immediate Execution to verify I have everything set. So I ruled out that the function is being called incorrectly.

The problem is I don't know if it needs a condition. I've read all kinds of stuff like making it a "Deferred Execution" rather than a "Rollback Execution" in the In-Script Execution.

I'm using InstallShield 2009 Pro in trial and got 7 days left. This is the last straw to purchasing this product. Everything else works great.
Labels (1)
0 Kudos
(9) Replies
RobertDickau
Flexera Alumni

A rollback action should be scheduled before the action it rolls back. Only deferred actions support rollback, and only the Execute sequence supports deferred actions, so you'll need to put the rollback action only in the Execute sequence. (Rollback mode is a kind of deferred mode, in fact.)

You shouldn't need a condition to detect rollback in general. For completeness' sake, uninstall actions generally need rollback actions too, in case the uninstallation fails during deferred mode, but first things first.
0 Kudos
Merima
Level 3

Just to make sure before I go about doing this. I don't want to do anymore trial and error work.

Currently my "InstallSqlDb" is in the User Interface Sequence all the way on the bottom. It is set to "Immediate Execution". So I can NOT put it in Execute Sequence until I make it a "Deffered Execution"? Correct?

Then I should put RollbackSqlDb right before that as "Rollback Execution"? Correct?


I'm trying to put InstallSqlDb as a deffered execution at different points and it no longer runs. I have a condition on it of "Not Installed"
0 Kudos
RobertDickau
Flexera Alumni

Correct, any action that makes system changes (and that might need to be rolled back) should be in the Execute sequence, scheduled for deferred execution (probably deferred in system context).

And correct, deferred execution actions (including rollback actions) need to be between InstallInitialize and InstallFinalize; if you depend on files being installed, your action should be scheduled after InstallFiles. Likewise any other dependencies on actions having already run.
0 Kudos
Merima
Level 3

I modified my post above while you were righting this. I put the installsqldb right before Installfinalize and it doesn't run like it did when I put it in the UI sequence? I want to get the installsqldb to work before I concentrate on why the rollback doesn't. In the Execute sequence will a messagebox show. Thats what I use as an indicator to make sure it runs.
0 Kudos
RobertDickau
Flexera Alumni

The help topics "Specifying the Signature for a Managed Method in an Assembly Custom Action" and "Run-Time Requirements for Managed-Code Custom Actions" might help, especially if you're using MSI properties in your deferred action code... Otherwise, creating an MSI log file at run time might help track down what's going on.
0 Kudos
Merima
Level 3

Here is the install log I got. From the help and researching on the net I realized that maybe the problem may be that I'm passing Installdir to the dll.
Could this be the reason I didn't really understand whats making it fail from the log:

MSI (s) (14:5C) [23:27:31:284]: Set LastUsedSource to: C:\InstallShield 2009 Projects\My Project Name-3\Product Configuration 1\Release 1\DiskImages\Disk1\.
MSI (s) (14:5C) [23:27:31:291]: Set LastUsedType to: n.
MSI (s) (14:5C) [23:27:31:296]: Set LastUsedIndex to: 1.
MSI (s) (14:5C) [23:27:31:303]: Executing op: ActionStart(Name=InstallSqlDB,,)
Action 23:27:31: InstallSqlDB.
MSI (s) (14:5C) [23:27:31:317]: Executing op: CustomActionSchedule(Action=InstallSqlDB,ActionType=3137,Source=BinaryData,Target=m1,)
MSI (s) (14:94) [23:27:31:325]: Invoking remote custom action. DLL: C:\Windows\Installer\MSI2DF8.tmp, Entrypoint: m1
MSI (s) (14:60) [23:27:31:327]: Generating random cookie.
MSI (s) (14:60) [23:27:31:339]: Created Custom Action Server with PID 4844 (0x12EC).
MSI (s) (14:04) [23:27:31:367]: Running as a service.
MSI (s) (14:04) [23:27:31:370]: Hello, I'm your 32bit Elevated custom action server.
InstallShield: Loaded CLR successfully
InstallShield: Deferred action requested property MsiHiddenProperties not provided by CustomActionData
InstallShield: Loading Assembly [#databaseinstaller.dll]
InstallShield: Resolving assembly filekey [#databaseinstaller.dll].
InstallShield: Deferred action requested property #databaseinstaller.dll not provided by CustomActionData
InstallShield: Could not resolve [#databaseinstaller.dll]; is "#databaseinstaller.dll=" part of CustomActionData?
InstallShield: Unable to load managed custom action assembly [#databaseinstaller.dll]
MSI (s) (14:5C) [23:27:31:502]: Executing op: End(Checksum=0,ProgressTotalHDWord=0,ProgressTotalLDWord=24760192)
MSI (s) (14:5C) [23:27:31:508]: User policy value 'DisableRollback' is 0
MSI (s) (14:5C) [23:27:31:513]: Machine policy value 'DisableRollback' is 0
Action 23:27:31: RollbackCleanup. Removing backup files
MSI (s) (14:5C) [23:27:31:540]: Calling SRSetRestorePoint API. dwRestorePtType: 0, dwEventType: 103, llSequenceNumber: 203, szDescription: "".
MSI (s) (14:5C) [23:27:31:542]: The call to SRSetRestorePoint API succeeded. Returned status: 0.
MSI (s) (14:5C) [23:27:31:547]: Unlocking Server
MSI (s) (14:5C) [23:27:31:547]: PROPERTY CHANGE: Deleting UpdateStarted property. Its current value is '1'.
Action ended 23:27:31: InstallFinalize. Return value 1.
Action ended 23:27:31: INSTALL. Return value 1.
0 Kudos
MichaelU
Level 12 Flexeran
Level 12 Flexeran

It doesn't look like you're passing any CustomActionData string to this action. To do so, set a property named identically to the action's name to the string you want it to receive.

Since you are using an installed file as the source for this deferred execution managed code custom action, you need to provide it the location as part of this. To do this, it's probably easiest to sequence a set-property custom action just before InstallSqlDB. If you also want to provide INSTALLDIR, it would look something like:
Property Name: InstallSqlDB
Property Value: #databaseinstaller.dll="[#databaseinstaller.dll]" INSTALLDIR="[INSTALLDIR]"
0 Kudos
Merima
Level 3

Thanks that worked great. However the rollback portion isn't!!

Ok I got the InstallSqlDB to work. Now when I want to do a rollback I set it up like in the attached screenshot.

Is a rollback initiated when you cancel the installation with the cancel button?

I don't get any mention of the rollback in RollbackSqlDB custom action that I created in the log.

I only have 5 days before the Installshield trial runs out and if I don't get it fixed by then I won't get approval for the purchase. Please help!
0 Kudos
RobertDickau
Flexera Alumni

Yes, rollback is triggered when a user clicks Cancel, though your rollback action won't run unless the Cancel comes after the action it rolls back.

To test, perhaps put an Error custom action after your InstallSqlDb action, scheduled for deferred mode?
0 Kudos