<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:ui="http://schemas.microsoft.com/wix/2010/ui"
     xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
    <Product Id="*" Name="{product_name_with_version}" Language="1033" Version="{version}"
        Manufacturer="{manufacturer}"
        UpgradeCode="{upgrade_code}">

        <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Platform="x64" />
        <Media Id="1" Cabinet="{asset_prefix}.cab" EmbedCab="yes" />
        
        <!-- Required property for WixUI_InstallDir dialog set -->
        <Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
        
        <!-- Application Icon -->
        <Icon Id="AppIcon.ico" SourceFile="{icon_ico}" />
        
        <!-- Custom branding for InstallDir dialog set -->
        <WixVariable Id="WixUIDialogBmp" Value="{dialog_bmp}" />
        <WixVariable Id="WixUIBannerBmp" Value="{banner_bmp}" />
        <WixVariable Id="WixUILicenseRtf" Value="{license_rtf}" />

        <!-- Installation UI dialogs -->
        <UIRef Id="WixUI_InstallDir" />
        <UIRef Id="WixUI_ErrorProgressText" />

        <!-- Close running application before installation -->
        <util:CloseApplication
            Target="{exe_name}.exe"
            CloseMessage="yes"
            RebootPrompt="no"
            ElevatedCloseMessage="no" />

        <Feature Id="ProductFeature" Title="{product_name}" Level="1">
            <ComponentGroupRef Id="AppFiles" />
            <ComponentRef Id="ProgramMenuShortcut" />
            <ComponentRef Id="DesktopShortcut" />
        </Feature>

        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFiles64Folder">
                <Directory Id="INSTALLFOLDER" Name="{install_dir_name}" />
            </Directory>
            <Directory Id="ProgramMenuFolder">
                <Directory Id="ApplicationProgramsFolder" Name="{product_name}"/>
            </Directory>
            <Directory Id="DesktopFolder" />
        </Directory>

        <DirectoryRef Id="ApplicationProgramsFolder">
            <Component Id="ProgramMenuShortcut" Guid="*">
                <Shortcut Id="ApplicationStartMenuShortcut"
                    Name="{product_name}"
                    Description="{shortcut_description}"
                    Target="[INSTALLFOLDER]{exe_name}.exe"
                    Icon="AppIcon.ico"
                    IconIndex="0"
                    WorkingDirectory="INSTALLFOLDER" />
                <RemoveFolder Id="ApplicationProgramsFolderRemove"
                    On="uninstall" />
                <RegistryValue Root="HKCU"
                    Key="Software\Microsoft\Windows\CurrentVersion\Uninstall\{exe_name}"
                    Name="installed"
                    Type="integer"
                    Value="1"
                    KeyPath="yes" />
            </Component>
        </DirectoryRef>

        <DirectoryRef Id="DesktopFolder">
            <Component Id="DesktopShortcut" Guid="*">
                <Shortcut Id="DesktopApplicationShortcut"
                    Name="{product_name}"
                    Description="{shortcut_description}"
                    Target="[INSTALLFOLDER]{exe_name}.exe"
                    Icon="AppIcon.ico"
                    IconIndex="0"
                    WorkingDirectory="INSTALLFOLDER" />
                <RegistryValue Root="HKCU"
                    Key="Software\{exe_name}"
                    Name="DesktopShortcut"
                    Type="integer"
                    Value="1"
                    KeyPath="yes" />
            </Component>
        </DirectoryRef>
    </Product>
</Wix>
