0

I need to setup a custom action within WiX 3.0. I have the following setup in my Windows application exe.

I have viewed the question at StackOverflow: Removing files when uninstalling Wix however I can't get this working with WiX 3.0. This seems to deal with InstallUtilLib.dll, however I can't work out how I call the custom action within my main Windows app executable.

Also, is there some method that I can use to manually invoke and test the OnBeforeUninstall function is working as expected?

Imports System.Configuration.Install.Installer
Imports System.IO

Public Class CustomInstaller
    Inherits Configuration.Install.Installer

    Protected Overrides Sub OnBeforeUninstall(ByVal savedState As System.Collections.IDictionary)
        MyBase.OnBeforeUninstall(savedState)

        Try

    End Sub

End Class
Community
  • 1
  • 1
Luke
  • 5,895
  • 11
  • 54
  • 84

1 Answers1

1

InstallUtil is an ugly antipattern. If you need a managed CustomAction you should use WiX's DTF pattern. Also you should attempt to avoid CustomActions all together whenever native WiX/MSI functionality will handle your needs. Have you tried to use the RemoveFile element?

Christopher Painter
  • 52,390
  • 6
  • 60
  • 97
  • RemoveFile won't remove subdirectories and files etc. I am dealing with isolated storage and removing the settings where I don't know the file names. How about if my app can remove settings with the command line "App.exe /reset"? How would I run that in the Programs Files before it is removed? – Luke May 23 '10 at 15:23
  • It is true, RemoveFile won't remove directories recursive. So here's how I roll.... I write an immeadiate custom action using C#/DTF that emits temporary records into the RemoveFiles table during the install. This way all I have to do is the business logic of what I need deleted. Window Installer then handles the actual execution of that deletion including rolling back the deletes if the uninstall is aborted. – Christopher Painter May 23 '10 at 18:18
  • Thanks, sounds fine. I have located an example of the DTF and WiX at http://www.tramontana.co.hu/wix/lesson3.php#3.5 However I notice that sfxca.dll is either x86 or x64. I only do one build of my application as the .NET framework will run it in 64bit if appropriate. Do I need to handle this manually in the custom action? – Luke May 24 '10 at 01:55
  • You probably want to choose x86 then. MSI isn't Any CPU, you have to say one or the other but by saying x86 you'll run in WOW64 on x64 as a 32bit process. Once installed your EXE can continue to be Any CPU. – Christopher Painter May 24 '10 at 19:30