oleg-shilo / wixsharp

Framework for building a complete MSI or WiX source code by using script files written with C# syntax.
MIT License
1.12k stars 176 forks source link

Capture Msi error in bootraper #324

Closed sanjuleo closed 6 years ago

sanjuleo commented 6 years ago

Hi Oleg I need to raise error in MSi and capture them in bootstraper to display a message or put them in bootstraper log. My MSi is running in silent mode. For now I am putting them through session.Log(error) and quitting the installation, but they do not display in bootstraper log and user has to go to temp folder to find the MSI log and find the error.

I found this link to capture MSI errors in BA - http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Handling-error-from-MSI-in-Custom-BA-td7600313.html

Do we have something similar in Bundle?

Regards

oleg-shilo commented 6 years ago

Yes you can do it for the BA implemented by yourself but you cannot control how the standard WixBA behave. The standard WixBA and implements its own error handling as WiX developers designed it and you have very limited customization options for it.

However if you are using your own BA (see 'WixBootstrapper_UI' sample) then you can use the same technique as the link you provided describes:

public class MainViewModel : INotifyPropertyChanged
{
    public MainViewModel(BootstrapperApplication bootstrapper)
    {
        this.Bootstrapper.Error += this.OnError;
        ...
    }

    void OnError(object sender, ErrorEventArgs e)
    {
        MessageBox.Show(e.ErrorMessage);
    }
    ...