<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension">

	<Product Id="*"
    Name="First Aid Service Desk (F4SD) Cockpit Client"
    Language="1033"
    Version="2.6.0.4"
    Manufacturer="Consulting4IT GmbH, Germany"
    UpgradeCode="42C65B2F-5482-4A02-9A4F-07F97C8BB008">

    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine"  Platform="x86"/>

    <Icon Id="Setup.ico" SourceFile="Img\logo_FASD.ico"/>

    <WixVariable Id="WixUILicenseRtf" Value="License.rtf"/>
    <WixVariable Id="WixUIBannerBmp" Value="Img\Banner.bmp"/>
    <WixVariable Id="WixUIDialogBmp" Value="Img\Dialog.bmp"/>

    <UIRef Id="WixUI_Dialogs" />

		<MajorUpgrade
      DowngradeErrorMessage="A newer version of [ProductName] is already installed."
      Schedule="afterInstallInitialize"
      AllowSameVersionUpgrades="yes"/>
    
    <Media Id="1" Cabinet="Install.cab" EmbedCab="yes" DiskPrompt="Setup.msi" />

    <Property Id='DiskPrompt' Value="F4SD Client installation source" />

    <Property Id="INSTALLLEVEL" Value="100"/>
    <Property Id="PARAM_AUTOSTART" Value="1" Secure="yes"/>
    <Property Id="PARAM_SERVER" Value="https://[Server-FQDN]/F4SDCockpit/" Secure="yes">
      <RegistrySearch Id="PARAM_SERVER_REG"
        Root="HKLM"
        Key="Software\Consulting4IT GmbH\First Aid Service Desk\Cockpit"
        Name="ServerUrl"
        Type="raw"/>
    </Property>
    <Property Id="ARPPRODUCTICON" Value="Setup.ico"/>
    <PropertyRef Id="NETFRAMEWORK45"/>

    <Condition Message="This application requires .NET Framework 4.7.2. Please install the .NET Framework then run this installer again."><![CDATA[Installed OR (NETFRAMEWORK45 >= "#461808")]]></Condition>

    <Feature Id="ProductFeature" Title="First Aid Service Desk" Level="1" Absent="disallow" AllowAdvertise="no" Display="expand" ConfigurableDirectory="INSTALLFOLDER" InstallDefault="local">
      <ComponentRef Id="ProgramMenuDir"/>
      <ComponentRef Id="MainExecutable"/>
      <ComponentRef Id="F4SD_Common"/>
      <ComponentRef Id="Configuration"/>
      <ComponentRef Id="Autostart"/>
      <ComponentRef Id="PhoneMonitor"/>
      <ComponentRef Id="WebViewRuntimeX64"/>
      <ComponentRef Id="WebViewRuntimeX86"/>
      <ComponentRef Id="WebViewRuntimeArm64"/>
    </Feature>

  </Product>

	<Fragment>
		<Directory Id="TARGETDIR" Name="SourceDir">
			<Directory Id="ProgramFilesFolder">
				<Directory Id="C4IT" Name="Consulting4IT">
          <Directory Id="INSTALLFOLDER" Name="First Aid Service Desk">
            <Directory Id="WebViewRt" Name="runtimes">
              <Directory Id="WebViewRtX64" Name="win-x64">
                <Directory Id="WebViewRtNativeX64" Name="native"/>
              </Directory>
              <Directory Id="WebViewRtX86" Name="win-x86">
                <Directory Id="WebViewRtNativeX86" Name="native"/>
              </Directory>
              <Directory Id="WebViewRtArm64" Name="win-arm64">
                <Directory Id="WebViewRtNativeArm64" Name="native"/>
              </Directory>
            </Directory>
          </Directory>
        </Directory>
			</Directory>
			<Directory Id="ProgramMenuFolder" Name="Programs">
        <Directory Id="ProgramMenuDir" Name="First Aid Service Desk">
            <Component Id="ProgramMenuDir" Guid="B791B054-8E8D-4107-9E28-4A1B46F68D29">
                <RemoveFolder Id='ProgramMenuDir' On="uninstall"/>
                <RegistryValue Root="HKMU" Key="Software\Consulting4IT GmbH\First Aid Service Desk\Cockpit" Type="string" Name="ProgramFolder" Value="1" KeyPath="yes" />
            </Component>
        </Directory>
      </Directory>
		</Directory>
	</Fragment>

	<Fragment>
		<ComponentGroup Id="ProductComponents" >
      <Component Id="MainExecutable" Guid="6870A6BE-C3CC-4308-A176-2AD860D60A48" Directory="INSTALLFOLDER">
          <File Id="F4SD_Cockpit_Client.exe" Name="F4SD-Cockpit-Client.exe" DiskId="1" Source="Source\F4SD-Cockpit-Client.exe" KeyPath="yes">
            <Shortcut Id="MainShortcut" Directory="ProgramMenuDir" Name="F4SD Cockpit" Icon="Icon.exe" Advertise="yes" IconIndex="0">
              <Icon Id="Icon.exe" SourceFile="Source\F4SD-Cockpit-Client.exe"/>
            </Shortcut>
          </File>
        <File Id="F4SD_Cockpit_Client.exe.config" Name="F4SD-Cockpit-Client.exe.config" DiskId="1" Source="Source\F4SD-Cockpit-Client.exe.config" KeyPath="no"/>
        <File Id="F4SD_Cockpit_Client_Base.dll" Name="F4SD-Cockpit-Client-Base.dll" DiskId="1" Source="Source\F4SD-Cockpit-Client-Base.dll" KeyPath="no"/>
        <File Id="F4SD_Cockpit_Client_Communication.dll" Name="F4SD-Cockpit-Client-Communication.dll" DiskId="1" Source="Source\F4SD-Cockpit-Client-Communication.dll" KeyPath="no"/>
        <File Id="F4SD_AdaptableIcon.dll" Name="F4SD-AdaptableIcon.dll" DiskId="1" Source="Source\F4SD-AdaptableIcon.dll" KeyPath="no"/>
        <File Id="C4IT_F4SD_DisplayFormatting.dll" Name="C4IT.F4SD.DisplayFormatting.dll" DiskId="1" Source="Source\C4IT.F4SD.DisplayFormatting.dll" KeyPath="no"/>
        <File Id="Newtonsoft.Json.dll" Name="Newtonsoft.Json.dll" DiskId="1" Source="Source\Newtonsoft.Json.dll" KeyPath="no"/>
        <File Id="Microsoft.Web.WebView2.Core.dll" Name="Microsoft.Web.WebView2.Core.dll" DiskId="1" Source="Source\Microsoft.Web.WebView2.Core.dll" KeyPath="no"/>
        <File Id="Microsoft.Web.WebView2.WinForms.dll" Name="Microsoft.Web.WebView2.WinForms.dll" DiskId="1" Source="Source\Microsoft.Web.WebView2.WinForms.dll" KeyPath="no"/>
        <File Id="Microsoft.Web.WebView2.Wpf.dll" Name="Microsoft.Web.WebView2.Wpf.dll" DiskId="1" Source="Source\Microsoft.Web.WebView2.Wpf.dll" KeyPath="no"/>
        <File Id="Microsoft.Extensions.Logging.Abstractions.dll" Name="Microsoft.Extensions.Logging.Abstractions.dll" DiskId="1" Source="Source\Microsoft.Extensions.Logging.Abstractions.dll" KeyPath="no"/>
      </Component>
      <Component Id="F4SD_Common" Guid="313E5AFD-D487-4029-BBAE-17EA697D133C" Directory="INSTALLFOLDER">
        <File Id="F4SD_Logging.dll" Name="F4SD-Logging.dll" DiskId="1" Source="Source\F4SD-Logging.dll" KeyPath="no"/>
        <File Id="MaterialIcons.dll" Name="MaterialIcons.dll" DiskId="1" Source="Source\MaterialIcons.dll" KeyPath="no"/>
        <File Id="WpfAnimatedGif.dll" Name="WpfAnimatedGif.dll" DiskId="1" Source="Source\WpfAnimatedGif.dll" KeyPath="no"/>
      </Component>
      <Component Id="Configuration" Guid="96DA1511-254F-4059-9A64-878435D88965" Directory="INSTALLFOLDER">
        <Condition><![CDATA[PARAM_SERVER<>""]]></Condition>
        <RegistryValue Root="HKMU" Key="Software\Consulting4IT GmbH\First Aid Service Desk\Cockpit" Type="string" Name="ServerUrl" Value="[PARAM_SERVER]" KeyPath="yes"/>
      </Component>
      <Component Id="Autostart" Guid="A368475A-B8AB-4580-89AE-FB414526EA34" Directory="INSTALLFOLDER">
        <Condition>PARAM_AUTOSTART="1"</Condition>
        <RegistryValue Root="HKMU" Key="SOFTWARE\Microsoft\Windows\CurrentVersion\Run" Type="string" Name="First Aid Service Desk" Value="&quot;[INSTALLFOLDER]F4SD-Cockpit-Client.exe&quot; silentstart" KeyPath="yes"/>
      </Component>
      <Component Id="PhoneMonitor" Guid="53AF46D5-96FF-4DD1-9897-8FB830CABC41" Directory="INSTALLFOLDER">
        <File Id="F4SDPhoneMonitor.exe" Name="F4SD-PhoneMonitor.exe" DiskId="1" Source="Source\F4SD-PhoneMonitor.exe" KeyPath="yes"/>
        <File Id="F4SDPhoneMonitor.exe.config" Name="F4SD-PhoneMonitor.exe.config" DiskId="1" Source="Source\F4SD-PhoneMonitor.exe.config" KeyPath="no"/>
        <File Id="Interop.CLMgr.dll" Name="Interop.CLMgr.dll" DiskId="1" Source="Source\Interop.CLMgr.dll" KeyPath="no"/>
        <File Id="Interop.TAPI3Lib.dll" Name="Interop.TAPI3Lib.dll" DiskId="1" Source="Source\Interop.TAPI3Lib.dll" KeyPath="no"/>
      </Component>
      <Component Id="WebViewRuntimeX64" Guid="640663E7-5C43-4A2A-91AB-2D092CB79091" Directory="WebViewRtNativeX64">
        <File Id="WebView2LoaderX64" Name="WebView2Loader.dll" DiskId="1" Source="Source\runtimes\win-x64\native\WebView2Loader.dll" KeyPath="yes"/>
      </Component>
      <Component Id="WebViewRuntimeX86" Guid="E6119BED-A53E-4741-9F5B-888BA88AA4CE" Directory="WebViewRtNativeX86">
        <File Id="WebView2LoaderX86" Name="WebView2Loader.dll" DiskId="1" Source="Source\runtimes\win-x86\native\WebView2Loader.dll" KeyPath="yes"/>
      </Component>
      <Component Id="WebViewRuntimeArm64" Guid="6917DB0D-E98A-45FA-9AA1-0A97FE8735D7" Directory="WebViewRtNativeArm64">
        <File Id="WebView2LoaderArm64" Name="WebView2Loader.dll" DiskId="1" Source="Source\runtimes\win-arm64\native\WebView2Loader.dll" KeyPath="yes"/>
      </Component>
    </ComponentGroup>
  </Fragment>
</Wix>