<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">

  <?include $(sys.CURRENTDIR)\Common.wxi?>

  <?define LightSwitchFiles=?>
  <?define LightSwitchFilesPath=$(var.BinDir)\LightSwitchService\?>

  <Fragment>
    <!-- Light Switch background service -->

    <!-- Create a directory for the service binaries -->
    <DirectoryRef Id="INSTALLFOLDER">
      <Directory Id="LightSwitchServiceFolder" Name="LightSwitchService" />
    </DirectoryRef>

    <!-- File components generated by generateAllFileComponents.ps1 -->
    <DirectoryRef Id="LightSwitchServiceFolder" FileSource="$(var.LightSwitchFilesPath)">
      <!-- Generated by generateFileComponents.ps1 -->
      <!--LightSwitchFiles_Component_Def-->
    </DirectoryRef>

    <!-- Group to include the service + cleanup on uninstall -->
    <ComponentGroup Id="LightSwitchComponentGroup">

      <!-- Ensures folder removal on uninstall -->
      <Component Id="RemoveLightSwitchServiceFolder" Guid="C1E2F2ED-34A2-4EB0-8E17-DC0535F50F9D" Directory="INSTALLFOLDER">
        <RegistryKey Root="$(var.RegistryScope)" Key="Software\Classes\powertoys\components">
          <RegistryValue Type="string" Name="RemoveLightSwitchServiceFolder" Value="" KeyPath="yes" />
        </RegistryKey>
        <RemoveFolder Id="RemoveFolderLightSwitchServiceFolder" Directory="LightSwitchServiceFolder" On="uninstall" />
      </Component>
    </ComponentGroup>
  </Fragment>
</Wix>
