Search code examples
wixwindows-installerwixsharp

How to implement rollback using Wixsharp (Wix#) installer


I'm new in MSI installers, wix and wixsharp. I need to implement installer with some actions during the installation process (like call some *.exe or set up task scheduler and so on). Bu in case of any problems and exceptions I need a rollback all installed items.

  1. How to implement a rollback using Wixsharp (Wix#) ? I found no information on the page of this porject.

  2. I can't figure out the practical difference between custom action and before\after install event handler. What for do I need to use exactly custom action, instead of isuage of AfterInstall even handler in wix# ?


Solution

  • The author of wix# helped me with rollback using permissions elevations and third party referencies to assemblies (most difficult case).

    Full answer is here: https://wixsharp.codeplex.com/discussions/646337

    in common way rollback can be done like this:

    project.AfterInstall += project_AfterInstall;
    ...
    static void project_AfterInstall(SetupEventArgs e)
    {
        try
        {
            //do your stuff
        }
        catch (Exception ex)
        {
            e.Session.Log(ex.Message);
            e.Result = ActionResult.Failure;
        }
    }