<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">

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

  <?define DscJsonFiles=?>
  <?define DscJsonFilesPath=$(var.BinDir)\DSCModules?>

  <Fragment>
    <DirectoryRef Id="DSCModulesReferenceFolder" FileSource="$(var.DscJsonFilesPath)">
      <!-- DSC v2 PowerShell module files -->
      <Component Id="PowerToysDSCReference" Guid="40869ACB-0BEB-4911-AE41-5E73BC1586A9" Bitness="always64">
        <RegistryKey Root="$(var.RegistryScope)" Key="Software\Classes\powertoys\components">
          <RegistryValue Type="string" Name="DSCModulesReference" Value="" KeyPath="yes" />
        </RegistryKey>
        <File Source="$(var.RepoDir)\src\dsc\Microsoft.PowerToys.Configure\Generated\Microsoft.PowerToys.Configure\$(var.Version).0\Microsoft.PowerToys.Configure.psd1" Id="PTConfReference.psd1" />
        <File Source="$(var.RepoDir)\src\dsc\Microsoft.PowerToys.Configure\Generated\Microsoft.PowerToys.Configure\$(var.Version).0\Microsoft.PowerToys.Configure.psm1" Id="PTConfReference.psm1" />
      </Component>
      
      <!-- DSC v3 JSON manifest files - Generated by generateAllFileComponents.ps1 -->
      <!--DscJsonFiles_Component_Def-->
    </DirectoryRef>

    <ComponentGroup Id="DscResourcesComponentGroup">
      <ComponentRef Id="PowerToysDSCReference" />
      <?if $(var.PerUser) = "false" ?>
      <Component Id="SecureDSCModulesFolder" Guid="7D2F4E57-CCB2-4F89-9B8B-62E9B3CC4E12" Directory="DSCModulesReferenceFolder" Bitness="always64">
        <RegistryKey Root="$(var.RegistryScope)" Key="Software\Classes\powertoys\components">
          <RegistryValue Type="string" Name="SecureDSCModulesFolder" Value="" KeyPath="yes" />
        </RegistryKey>
        <CreateFolder>
          <PermissionEx Sddl="D:PAI(A;OICI;GA;;;SY)(A;OICI;GA;;;BA)(A;OICI;GRGX;;;BU)(A;OICIIO;GA;;;CO)" />
        </CreateFolder>
      </Component>
      <?endif?>
      <Component Id="RemoveDSCModulesFolder" Guid="A3C77D92-4E97-4C1A-9F2E-8B3C5D6E7F80" Directory="DSCModulesReferenceFolder">
        <RegistryKey Root="$(var.RegistryScope)" Key="Software\Classes\powertoys\components">
          <RegistryValue Type="string" Name="RemoveDSCModulesFolder" Value="" KeyPath="yes" />
        </RegistryKey>
        <RemoveFolder Id="RemoveDSCModulesReferenceFolder" Directory="DSCModulesReferenceFolder" On="uninstall" />
      </Component>
    </ComponentGroup>
  </Fragment>
</Wix>
