\
Tips and Tricks
Debug Macro - Cause Rollback (or just failure)
Debug Macro - Cause Rollback (or just failure) |
This demonstrates a relatively simple but very useful debugging macro
with can be used for two main reasons:
- You wish to test other
rollback custom actions
by simulating a failure during an install.
- You want to test something over and over without the need to
restore state yourself, for example you want to test install
but don't wish to keep uninstalling it!
This command causes a failure.
By default it creates "deferred custom actions"
scheduled as close as possible to "InstallFinalize" to try to cover all
rollbackable installation activity.
The 'DebugCauseFailure' (or 'DebugRollback') Code |
;-----------------------------------------------------------------------------
;--- DEBUG MACRO: RollBack (use to abort install/repair/uninstall activity ---
;-----------------------------------------------------------------------------
#( '<?NewLine>'
#define DebugRollback ;;Version 08.241
;--- Validate parameters and keep count ---------------------------------
{$!:SEQ,SEQTABLE,TYPE,CONDITION}
#RexxVar RxDebugRollBackCnt + 1 ;;Inc Count (need diff binaries as conditions, scheduling may/will differ)
;--- Don't do anything in production mode! ------------------------------
#if ['<$MmMode>' = '<$MMMODE_PRODUCTION>']
;--- In production mode warn first time -----------------------------
#if [RxDebugRollBackCnt = 1]
#info ^DebugRollback not inserted in production mode!^
#endif
#elseif
;--- Not Production mode --------------------------------------------
<$VbsCa Binary="DebugRollback_<??RxDebugRollBackCnt>.vbs">
<$VbsCaEntry "FailedOnPurpose">
#(
VbsCaRaiseError "FailedOnPurpose()",
"<$DebugCauseFailureMsg>" & vbCRLF &
vbCRLF &
"MSI : <$ProdInfo.ProductName> v<$ProductVersion> (build <?CompileTime>)" & vbCRLF &
"Sequenced : {$Seq=^<-InstallFinalize^} (in {$SeqTable=^InstallExecuteSequence^})" & vbCRLF &
"Condition : {$Condition=~<$CONDITION_INSTALL_ONLY>~}" & vbCRLF &
"CA Type : {$Type=^Deferred^}" & vbCRLF &
"Defined : <??RxMmLocation>"
#)
<$/VbsCaEntry>
<$/VbsCa>
<$VbsCaSetup Binary="DebugRollback_<??RxDebugRollBackCnt>.vbs" Entry="FailedOnPurpose" Seq="{$Seq}" CONDITION=^{$Condition}^ Type="{$Type}" SeqTable="{$SeqTable}">
#endif
#)
#RexxVar RxDebugRollBackCnt = 0 ;;Init count
#(
#define? DebugCauseFailureMsg
We are causing a failure on purpose,
perhaps to test rollback or because we want to test an install
over and over again without needing to uninstall all the time!
#)
#define DebugCauseFailure <$DebugRollback {$?}> ;;Create an alias for the macro.
The follow shows how the macro could be used:
<$DebugRollback>