<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
  <?ifndef var.VERSION?>
     <?error VERSION must be defined via command line argument?>
  <?endif?>
  <Bundle Name="Podman" Version="$(var.VERSION)" Manufacturer="Red Hat" UpgradeCode="f3e1f40a-a791-49b7-9bc6-050975293353" IconSourceFile="resources\podman-logo.ico" Compressed="yes">
    <BootstrapperApplication>
      <bal:WixStandardBootstrapperApplication LicenseUrl="" Theme="hyperlinkSidebarLicense" ThemeFile="podman-theme.xml" LocalizationFile="podman-theme.wxl" LogoFile="resources\podman-banner2.png" LogoSideFile="resources\podman-sidebar.png" SuppressOptionsUI="yes" ShowVersion="yes" />
    </BootstrapperApplication>
    <Variable Name="InstallFolder" Type="formatted" Value="[ProgramFiles64Folder]RedHat\Podman" bal:Overridable="yes" />
    <Variable Name="VERSION" Value="$(var.VERSION)" />
    <Variable Name="MachineProvider" Type="string" Value="wsl" bal:Overridable="yes" />
    <Variable Name="AllowOldWin" Type="numeric" Value="0" bal:Overridable="yes" />
    <Variable Name="LaunchTarget" Value="explorer.exe" />
    <Variable Name="LaunchArguments" Value="&quot;[InstallFolder]\podman-for-windows.html&quot;" />
    <Variable Name="SkipConfigFileCreation" Value="0" bal:Overridable="yes" />

    <util:RegistrySearch Id="PreviousVersionSearch" Variable="PreviousVersion" Result="value" Root="HKLM" Key="SOFTWARE\[WixBundleManufacturer]\Updates\[WixBundleName]" Value="PackageVersion" />
    <util:RegistrySearch Id="PreviousInstallFolderSearch" Root="HKLM" Key="SOFTWARE\[WixBundleManufacturer]\[WixBundleName]" Value="InstallDir" Variable="PreviousInstallFolder" Bitness="always64" />
    <util:DirectorySearch Path="[PreviousInstallFolder]" Variable="InstallFolder" After="PreviousInstallFolderSearch" Condition="PreviousInstallFolder" />
    <util:RegistrySearch Id="CurrentBuild" Variable="CBNumber" Result="value" Root="HKLM" Key="SOFTWARE\Microsoft\Windows NT\CurrentVersion" Value="CurrentBuildNumber" />
    <bal:Condition Message="Windows 10 (19041) or later is required to run this application." Condition="VersionNT &gt;= v10.0 AND (CBNumber &gt;= 19041 OR AllowOldWin = 1)" />
    <bal:Condition Message="You have an installed development, pre-release version, or alternative build identifying as the same version of this installer. You must uninstall the existing version of Podman first, before proceeding." Condition="WixBundleInstalled OR WixBundleForcedRestartPackage OR PreviousVersion &lt;&gt; VERSION" />
    <!-- Next condition blocks upgrades from v5.3.1. That's because that version
         of the installer has a bug (that got patched in v5.3.2) and upgrading
         from v5.3.1 requires upgrading to v5.3.2 first.
         c.f. https://github.com/containers/podman/issues/24735 -->
    <bal:Condition Message="You have v5.3.1 of Podman installed and upgrading to this version is not allowed. You must upgrade to v5.3.2 first." Condition="PreviousVersion &lt;&gt; v5.3.1" />
    <Chain>
      <MsiPackage Id="Setup" SourceFile="en-US\podman.msi" Vital="yes">
        <MsiProperty Name="INSTALLDIR" Value="[InstallFolder]" />
        <MsiProperty Name="MACHINE_PROVIDER" Value="[MachineProvider]" />
        <MsiProperty Name="SKIP_CONFIG_FILE_CREATION" Value="[SkipConfigFileCreation]" />
      </MsiPackage>
    </Chain>
    <OptionalUpdateRegistration />
  </Bundle>
</Wix>
