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

Install new web app if one already existed. #1020

Closed vinil2001 closed 3 years ago

vinil2001 commented 3 years ago

Dear Oleg,

first, of all, I would like to say Thank you for your huge work of a WixSharp. It is a very easy and useful tool.

I would like to ask your advice on one issue. How (using wixSharp) create an installer that will create one web app if another one was already installed, before. And It should happen from one MSI file.

Could wixSharp help with it?

Thank you in advance for you reply.

oleg-shilo commented 3 years ago

Hi Andriй,

Thank you, I am glad you like WixSharp. 😄

Yes I think WixSharp can help you with your problem

Web app As for Web app install, have a look at IIS_ASP_NETApp.

Conditional install And for the conditional install, you may want to have a look LaunchCondition sample. Simply check if the app is installed and then allow the session to proceed. Though you will need to rely on the custom property that you need to set based on the presence of another web app. While it is a canonical WiX/MSI way, I do not like it. Too convoluted.

So I prefer managed events. Very straight forward. This is the code from the CustomUI.Sequence sample. You only need to replace AppSearch.IsProductInstalled with your custom routine:

var project = new ManagedProject("ManagedSetup", . . .

project.UIInitialized += CheckCompatibility; //will be fired on the embedded UI start
project.Load += CheckCompatibility;          //will be fired on the MSI start

. . .

static void CheckCompatibility(SetupEventArgs e)
{
    if (e.IsInstalling)
    {
        var conflictingProductCode = "{1D6432B4-E24D-405E-A4AB-D7E6D088C111}";

        if (AppSearch.IsProductInstalled(conflictingProductCode))
        {
            string msg = "Installed '{0}' is incompatible with this product.\n" +
                         "Setup will be aborted."
                         .FormatWith(AppSearch.GetProductName(conflictingProductCode) ?? conflictingProductCode);

            MessageBox.Show(msg, "Setup");
            e.Result = ActionResult.UserExit;
        }
    }
}

Samples: https://github.com/oleg-shilo/wixsharp/tree/master/Source/src/WixSharp.Samples/Wix%23%20Samples

vinil2001 commented 3 years ago

Hi Oleg,

I think it is a good way.

Thank you for the suggested solution, will try it in nearest future.

Have a good day.