Search code examples
wpfwixwixsharp

WixSharp: Is it Possible to set the Product(Msi)-Name dynamic?


for my WPF-Project I want to create an installer with WixSharp. But I also want to install the same Project with different Names and configuration-files (DEV, TEST, LIVE).

Is this possible and how?
Do I need different Project-Guid's for each Installation?
If it's not possible: Is there a workaround?

Thx


Solution

  • Yes, it's possible for Wix & Wixsharp. What's you needs:

    1. Add CustomAction before ValidateProductID
    2. Change ProductName property in the session

    CustomAction managed code example:

    new ManagedAction(
        RenameProductName,
        Return.ignore,
        When.Before,
        Step.ValidateProductID,
        Condition.Always)
        {
            Impersonate = false,
            ActionAssembly = System.Reflection.Assembly.GetExecutingAssembly().Location
        };
    

    CustomAction code source:

    [CustomAction]
    public static ActionResult RenameProductName(Session session)
    {
        session["ProductName"] = "My new product name";
        return ActionResult.Success;
    }