oleg-shilo/wixsharp

Allow specifying the Group name when adding a FirewallException

Germs2004 opened this issue · 2 comments

Please add a feature to WixSharp that allows us to specify the "Group" name when adding a new FirewallException rule. It appears that WixToolkit has a property named "Grouping" for this, though I haven't tested it.

I suggest adding a new "Group" property that works like this:

FirewallException fwAllowRule1 = new()
{
    Feature = featureFirewallRules,
    Scope = FirewallExceptionScope.any,
    Name = "Contoso Web Server",
    Description = "This is my new rule to allow Contoso Web Server to connect.",
    Group = "Contoso"
};
FirewallException fwAllowRule2 = new()
{
    Feature = featureFirewallRules,
    Scope = FirewallExceptionScope.any,
    Name = "Contoso Data Server",
    Description = "This is my new rule to allow Contoso Data Server to connect.",
    Group = "Contoso"
};

screenshot of the Windows Firewall table showing the Group column that I'd like to be able to edit:
image

As a workaround, I think the only way to do this currently is to not use the FirewallException object, but call a Powershell script instead, which supports specifying the Group. Here is a Powershell command for that:
New-NetFirewallRule -DisplayName "Contoso Web Server" -Direction Inbound -Program "C:\Contoso\webserver.exe" -Action Allow -Group "Contoso"

WixSharp actually supports specifying WiX attributes that are not directly mapped to the WixSharp entities properties. Thus you can easily achieve the desired result by using a generic property AtributesDefinition:

image
image

Note, this attribute is only available in WiX5 (not WiX4) so if you do not have it installed globally you might need to do it from the code for your specific project:

WixTools.SetWixVersion(Environment.CurrentDirectory, "5.0.0");

var project = new Project("MyProduct", . . . 

But I added the dedicated property so it will be available in the very next release.

Excellent, thank you for the perfect workaround and for adding the new property. AttributesDefinition worked perfectly. (and thanks for WixSharp, because Wix is terribly difficult without it)