<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">
  <Bundle Name="Elwig" Manufacturer="Elwig" Version="!(bind.packageVersion.ElwigMsi)" UpgradeCode="f3c8fcab-c37c-43aa-9ab8-e42f4bb518b7"
          IconSourceFile="$(var.ElwigProjectDir)\Resources\Images\Elwig.ico">
    <BootstrapperApplication>
      <bal:WixStandardBootstrapperApplication LocalizationFile="HyperlinkTheme.wxl" LicenseUrl="" Theme="hyperlinkLicense" LogoFile="$(var.ElwigProjectDir)\Resources\Images\Elwig.png"
                                              SuppressOptionsUI="yes" ShowVersion="yes"/>
    </BootstrapperApplication>

    <util:RegistrySearch Id="VCredistx86" Variable="VCredistx86" Result="exists"
                         Root="HKLM" Key="SOFTWARE\Classes\Installer\Dependencies\VC,redist.x86,x86,14.36,bundle"/>
    <util:RegistrySearch Id="Webview2Machine" Variable="Webview2Machine" Result="exists"
                         Root="HKLM" Key="SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}"/>
    <util:RegistrySearch Id="Webview2User" Variable="Webview2User" Result="exists"
                         Root="HKCU" Key="Software\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}"/>

    <Chain>
      <ExePackage Id="VCredistx86Installer" DisplayName="VC Redist x86 installer" Name="VC_redist.x86.exe"
                  SourceFile="$(ProjectDir)\Files\VC_redist.x86.exe"
                  Cache="remove" Compressed="yes" PerMachine="yes" Permanent="yes" Vital="yes"
                  InstallArguments="/install /passive /norestart" DetectCondition="VCredistx86"/>
      <ExePackage Id="MicrosoftEdgeWebview2" DisplayName="Microsoft Edge Webview2 Runtime" Name="MicrosoftEdgeWebview2Setup.exe"
                  SourceFile="$(ProjectDir)\Files\MicrosoftEdgeWebview2Setup.exe"
                  Cache="remove" Compressed="yes" PerMachine="yes" Permanent ="yes" Vital="no"
                  InstallArguments="/silent /install" UninstallArguments="/silent /uninstall" DetectCondition="Webview2Machine OR Webview2User"/>
      <MsiPackage Id="ElwigMsi" SourceFile="$(var.Installer.TargetDir)\Elwig.msi" Permanent="no" Compressed="yes" Vital="yes"/>
    </Chain>
  </Bundle>
</Wix>
