El viernes, 20 de diciembre de 2013, escribió: > Hello, > > I have a custom action that moves some deprecated files from an > old install to a temp directory during a major upgrade and I have another > custom action to move them back that runs only during roll back. I am > having trouble accessing the two properties set by the first custom action > in my rollback custom action every time I access the CustomActionData > dictionary in my rollback action it is empty even though in the MSI log I > can clearly see it got set to the proper values. > > Below are the custom action definitions: > > <CustomAction > Id="DeleteUserAdminDeprecatedFiles" BinaryKey="FileSearchCA" > DllEntry="DeleteDeprecatedFiles" Execute="immediate" Return="check" /> > > <CustomAction Id="RestoreDeprecatedFiles" > BinaryKey="FileSearchCA" DllEntry="RestoreDeprecatedFiles" > Execute="rollback" Return="ignore"/> > > <CustomAction Id="SetRollbackData" > Property="RestoreDeprecatedFiles" > Value="RootDir=[DEPRECATEDFILESROOTDIR];TempDir=[DEPRECATEDTEMPORARYDIR]" /> > > Below is the scheduling of the actions: > > <Custom > Action="SetRollbackData" After="DeleteDeprecatedFiles"> > > OLD_VERSION_FOUND OR > <!--Run if we are doing a major upgrade (msi > -> msi).--> > > REMOVEINSTALLSHIELD > </Custom> > <Custom > Action="DeleteDeprecatedFiles" Before="InstallFinalize"> > > OLD_VERSION_FOUND OR > <!--Run if we are doing a major upgrade (msi > -> msi).--> > > REMOVEINSTALLSHIELD > <!--Run if we are upgrading installshield > instance.--> > </Custom> > <Custom > Action="RestoreDeprecatedFiles" After="InstallInitialize"/> > > Below are the relevant Log entries: > > MSI (s) (20:D4) [07:53:29:229]: Doing action: DeleteDeprecatedFiles > Action 7:53:29: DeleteDeprecatedFiles. > Action start 7:53:29: DeleteDeprecatedFiles. > MSI (s) (20:2C) [07:53:29:237]: Invoking remote custom action. DLL: > C:\Windows\Installer\MSI2DDF.tmp, Entrypoint: DeleteDeprecatedFiles > SFXCA: Extracting custom action to temporary directory: > C:\Windows\Installer\MSI2DDF.tmp-\ > SFXCA: Binding to CLR version v4.0.30319 > Calling custom action > FileSearchCA!FileSearchCA.FileSearchCA.DeleteDeprecatedFiles > Starting UserAdmin delete deprecated files Custom Action. > MSI (s) (20!A4) [07:53:29:413]: PROPERTY CHANGE: Adding > DEPRECATEDFILESROOTDIR property. Its value is 'C:\Program Files\Duck Creek > Technologies\ExampleUserAdmin\bin'. > MSI (s) (20!A4) [07:53:29:417]: PROPERTY CHANGE: Adding > DEPRECATEDTEMPORARYDIR property. Its value is > 'C:\Users\LMUser\AppData\Local\Temp\kg2s3d3v.vqo'. > Action ended 7:53:29: DeleteDeprecatedFiles. Return value 1. > MSI (s) (20:D4) [07:53:29:458]: Doing action: SetRollbackData > Action 7:53:29: SetRollbackData. > Action start 7:53:29: SetRollbackData. > MSI (s) (20:D4) [07:53:29:465]: PROPERTY CHANGE: Adding > RestoreDeprecatedFiles property. Its value is 'RootDir=C:\Program > Files\Duck Creek > Technologies\ExampleUserAdmin\bin;TempDir=C:\Users\LMUser\AppData\Local\Temp\kg2s3d3v.vqo'. > Action ended 7:53:29: SetRollbackData. Return value 1. > MSI (s) (20:D4) [07:53:29:469]: Doing action: InstallFinalize > Action 7:53:29: InstallFinalize. > > > > > Rollback: RestoreDeprecatedFiles > MSI (s) (20:D4) [07:55:19:904]: Executing op: > ActionStart(Name=RestoreDeprecatedFiles,,) > MSI (s) (20:D4) [07:55:19:906]: Executing op: > CustomActionRollback(Action=RestoreDeprecatedFiles,ActionType=1345,Source=BinaryData,Target=RestoreDeprecatedFiles,) > MSI (s) (20:60) [07:55:19:910]: Invoking remote custom action. DLL: > C:\Windows\Installer\MSIDE33.tmp, Entrypoint: RestoreDeprecatedFiles > SFXCA: Extracting custom action to temporary directory: > C:\Windows\Installer\MSIDE33.tmp-\ > SFXCA: Binding to CLR version v4.0.30319 > Calling custom action > FileSearchCA!FileSearchCA.FileSearchCA.RestoreDeprecatedFiles > Starting rollback for Deprecated files. > Printing CustomActionData. > Error in Rollback Deprecated files... > System.Collections.Generic.KeyNotFoundException > The given key was not present in the dictionary. > at System.Collections.Generic.Dictionary`2.get_Item(TKey key) > at FileSearchCA.FileSearchCA.RestoreDeprecatedFiles(Session session) > MSI (s) (20:D4) [07:55:20:578]: Executing op: > End(Checksum=0,ProgressTotalHDWord=0,ProgressTotalLDWord=0) > MSI (s) (20:D4) [07:55:20:581]: Error in rollback skipped. Return: 5 > MSI (s) (20:D4) [07:55:20:611]: Note: 1: 2318 2: > MSI (s) (20:D4) [07:55:20:614]: No System Restore sequence number for this > installation. > MSI (s) (20:D4) [07:55:20:616]: Unlocking Server > MSI (s) (20:D4) [07:55:20:631]: PROPERTY CHANGE: Deleting UpdateStarted > property. Its current value is '1'. > Action ended 7:55:20: INSTALL. Return value 3. > > Also for good measure the relevant code in the custom action: > > [CustomAction] > public static ActionResult > RestoreDeprecatedFiles(Session session) > { > try > { > > session.Log("Starting rollback for Deprecated files."); > > > session.Log("Printing CustomActionData."); > > foreach (var > kvp in session.CustomActionData) > { > > session.Log("{0} = {1}", kvp.Key, kvp.Value); > } > > > string > deprecatedRootDir = session.CustomActionData["RootDir"]; > string > deprecatedTempDir = session.CustomActionData["TempDir"]; > > var di = new > DirectoryInfo(deprecatedRootDir); > var tempDir = > new DirectoryInfo(deprecatedTempDir); > > if (!di.Exists) > { > > di.Create(); > } > > foreach (var > fi in tempDir.EnumerateFiles()) > { > > fi.MoveTo(Path.Combine(di.FullName, fi.Name)); > } > > return > ActionResult.Success; > } > catch (Exception e) > { > > session.Log("Error in Rollback Deprecated files..."); > > session.Log(e.GetType().ToString()); > > session.Log(e.Message); > > session.Log(e.StackTrace); > > return > ActionResult.Success; > } > }
If I understand correctly, you want to delete the files, and the only reason why you're moving them to a temporary directory is to support rollback. Wouldn't it be better to have a custom action that simply adds entries to the RemoveFile table, and let Windows Installer handle the deleting and rollback handling for you? -- Nicolás ------------------------------------------------------------------------------ Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk _______________________________________________ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users