Wixsharp: bal:Condition in bootstrapper

Created on 15 Mar 2018  路  2Comments  路  Source: oleg-shilo/wixsharp

Hello, is there a way to add the BalExtension condition to the bootstrapper standard application?

<bal:Condition Message="Some string"> <My Condition> </bal:Condition>

Done / Released enhancement question

Most helpful comment

Your post prompted me to revise the current support IGenricItems, which in case of Bundle is limited to Bundle.Variables only.

I have submitted the changes to the Bundle class, which will allow user define generic items to be added to the Bundle. This is how you will be able to add your own WixSharp extensions (bal:Condition), which are otherwise unavailable out of box:

```C#
class BalCondition : WixEntity, IGenericEntity
{
public string Condition;

public string Message;

public void Process(ProcessingContext context)
{
    context.Project.Include(WixExtension.Bal); //indicate that candle needs to use WixBlExtension.dll

    var element = new XElement(WixExtension.Bal.ToXName("Condition"), Condition)
                      .SetAttribute("Message", Message);

    context.XParent.Add(element);
}

}
...
bootstrapper.Items.Add(new BalCondition
{
Condition = "some condition",
Message = "Warning: ..."
});
```

All 2 comments

You can do it in XML generation event:
C# bootstrapper.WixSourceGenerated += (XDocument doc) => { doc.FindFirst("Bundle") .AddElement(new XElement(WixExtension.Bal.ToXName("Condition"), "my_condition")) .SetAttribute("Message", "my_warning"); };

Your post prompted me to revise the current support IGenricItems, which in case of Bundle is limited to Bundle.Variables only.

I have submitted the changes to the Bundle class, which will allow user define generic items to be added to the Bundle. This is how you will be able to add your own WixSharp extensions (bal:Condition), which are otherwise unavailable out of box:

```C#
class BalCondition : WixEntity, IGenericEntity
{
public string Condition;

public string Message;

public void Process(ProcessingContext context)
{
    context.Project.Include(WixExtension.Bal); //indicate that candle needs to use WixBlExtension.dll

    var element = new XElement(WixExtension.Bal.ToXName("Condition"), Condition)
                      .SetAttribute("Message", Message);

    context.XParent.Add(element);
}

}
...
bootstrapper.Items.Add(new BalCondition
{
Condition = "some condition",
Message = "Warning: ..."
});
```

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JasShao picture JasShao  路  4Comments

meytes picture meytes  路  5Comments

mgkeeley picture mgkeeley  路  5Comments

yfnfif picture yfnfif  路  3Comments

kain64 picture kain64  路  4Comments