Wixsharp: File firewall exceptions are ignored

Created on 26 Sep 2019  路  1Comment  路  Source: oleg-shilo/wixsharp

Firewall exceptions added to the File.FirewallExceptions collection is ignored when building a MSI file.

Is this modified example from your samples the firewall exceptions is added to the EXE file but is missing from MyProduct.wxs.

setup.cs:

//css_dir ..\..\;
//css_ref Wix_bin\SDK\Microsoft.Deployment.WindowsInstaller.dll;
//css_ref System.Core.dll;
using System;
using WixSharp;

class Script
{
    static public void Main()
    {
        var project =
            new Project("MyProduct",
                new Dir(@"%ProgramFiles%\My Company\My Product",
                    new File(@"Files\Bin\MyApp.exe")
                )
            );

        foreach (var file in project.AllFiles)
        {
            if (file.Id == "MyApp.exe")
            {
                Console.WriteLine("Firewall exception for MyApp.exe!");

                file.FirewallExceptions = new FirewallException[]
                {
                    new FirewallException
                    {
                        Name = "My Product",
                        Scope = FirewallExceptionScope.any,
                        Profile = FirewallExceptionProfile.all
                    }
                };
            }
        }

        project.UI = WUI.WixUI_InstallDir;
        project.GUID = new Guid("6f330b47-2577-43ad-9095-1861ba25889b");
        project.EmitConsistentPackageId = true;
        project.PreserveTempFiles = true;

        project.BuildMsi();
    }
}

MyProduct.wxs:

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Product Id="6f330b47-2577-43ad-9095-1861ca25889c" Name="MyProduct" Language="1033" Codepage="Windows-1252" Version="1.0.0.0" UpgradeCode="6f330b47-2577-43ad-9095-1861ba25889b" Manufacturer="ddm">
    <Package InstallerVersion="200" Compressed="yes" SummaryCodepage="Windows-1252" Languages="1033" Id="6f330b47-2577-43ad-9095-1861ca25889c" />
    <Media Id="1" Cabinet="MyProduct.cab" EmbedCab="yes" />

    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder" Name="ProgramFilesFolder">
        <Directory Id="ProgramFilesFolder.My_Company" Name="My Company">
          <Directory Id="INSTALLDIR" Name="My Product">

            <Component Id="Component.MyApp.exe" Guid="6f330b47-2577-43ad-9095-1861f9b9286d">
              <File Id="MyApp.exe" Source="Files\Bin\MyApp.exe" />
            </Component>

          </Directory>
        </Directory>
      </Directory>
    </Directory>

    <UIRef Id="WixUI_InstallDir" />
    <UIRef Id="WixUI_ErrorProgressText" />

    <Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" />

    <Feature Id="Complete" Title="Complete" Absent="allow" Level="1">
      <ComponentRef Id="Component.MyApp.exe" />
    </Feature>

  </Product>
</Wix>

Thereis is a workaround (maybe) by using the "File.GenericItems" collection it seams to work:

file.GenericItems = new IGenericEntity[]
{
    new FirewallException
    {
        Name = "My Product",
        Scope = FirewallExceptionScope.any,
        Profile = FirewallExceptionProfile.all
    }
};
<Component Id="Component.MyApp.exe" Guid="6f330b47-2577-43ad-9095-1861f9b9286d">
  <File Id="MyApp.exe" Source="Files\Bin\MyApp.exe">
    <FirewallException Id="My_Product_" Name="My Product" Profile="all" Scope="any" xmlns="http://schemas.microsoft.com/wix/FirewallExtension" />
  </File>
</Component>
Done / Released bug

Most helpful comment

Thank you, will have a look at it.

>All comments

Thank you, will have a look at it.

Was this page helpful?
0 / 5 - 0 ratings