<?xml version='1.0' encoding='windows-1252'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
    <?if $(var.Arch) = x64 ?>
        <?define ProgramFiles = "ProgramFiles64Folder" ?>
    <?else ?>
        <?define ProgramFiles = "ProgramFilesFolder" ?>
    <?endif ?>
    <Product Name="Adonthell - Waste's Edge"
        Manufacturer='The Adonthell Team'
        Id='*'
        UpgradeCode='9EC3DA40-20DB-4892-8EE9-0B04207B0EE5'
        Language='1033'
        Codepage='1252'
        Version='$(var.Version)'>
        <Package
            Id='*'
            Keywords='Installer'
            Platform="$(var.Arch)"
            Description="Adonthell Waste's Edge $(var.Version) Installer"
            Comments='© 2016 The Adonthell Team'
            Manufacturer='The Adonthell Team'
            InstallerVersion='200'
            Languages='1033'
            Compressed='yes'
            SummaryCodepage='1252' />
        <MajorUpgrade
            AllowSameVersionUpgrades="yes"
            DowngradeErrorMessage="A newer version of [ProductName] is already installed. If you are sure you want to downgrade, remove the existing installation via Programs and Features." />
        <Media Id='1' Cabinet='Wastesedge.cab' EmbedCab='yes' />
        <Icon Id="wastesedge.ico" SourceFile="SourceDir\bin\wastesedge.ico"/>
        <Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Launch Adonthell - Waste's Edge." />
        <Property Id="ARPPRODUCTICON" Value="wastesedge.ico" />
        <Directory Id='TARGETDIR' Name='SourceDir'>
            <Directory Id='$(var.ProgramFiles)' Name='PFiles'>
                <Directory Id='Adonthell' Name='Adonthell'>
                    <Directory Id='INSTALLDIR' Name='Wastesedge' >
                        <?if $(var.HaveManual) = 1 ?>
                            <Component Id='Manual' Guid='*'>
                                <File Id='Manual' Name='User Manual.pdf' DiskId='1' Source='..\User Manual.pdf' KeyPath='yes'>
                                    <Shortcut Id="startmenuManual" Directory="ProgramMenuDir" Name="User Manual" Advertise="yes" />
                                </File>
                            </Component>
                        <?endif ?>
                    </Directory>
                </Directory>
            </Directory>
            <Directory Id="ProgramMenuFolder" Name="Programs">
                <Directory Id="ProgramMenuDir" Name="Adonthell">
                    <Component Id="ProgramMenuIcon" Guid="*">
                        <Shortcut Id="startmenuShortcut"
                            Directory="ProgramMenuDir"
                            Name="Waste's Edge"
                            Target="[INSTALLDIR]bin\adonthell-0.3.exe"
                            Arguments="wastesedge"
                            WorkingDirectory='INSTALLDIR'
                            Icon="wastesedge.ico"
                            IconIndex="0"
                            Advertise="no" />
                        <RemoveFolder Id='ProgramMenuDir' On='uninstall' />
                        <RegistryValue Root='HKCU' Key='Software\[Manufacturer]\[ProductName]' Name='startmenuShortcut' Type='string' Value='' KeyPath='yes' />
                    </Component>
                </Directory>
            </Directory>
            <Directory Id="DesktopFolder" Name="Desktop">
                <Component Id='DesktopIcon' Guid='*'>
                    <Shortcut Id="desktopShortcut"
                        Directory="DesktopFolder"
                        Name="Adonthell - Waste's Edge"
                        Target="[INSTALLDIR]bin\adonthell-0.3.exe"
                        Arguments="wastesedge"
                        WorkingDirectory='INSTALLDIR'
                        Icon="wastesedge.ico"
                        IconIndex="0"
                        Advertise="no" />
                    <RegistryValue Root='HKCU' Key='Software\[Manufacturer]\[ProductName]' Name='desktopShortcut' Type='string' Value='' KeyPath='yes' />
                </Component>
            </Directory>
        </Directory>
        <Feature Id='Program'
            Level='1'
            Title="Adonthell - Waste's Edge"
            Description='Install program and data files'
            Absent='disallow'
            AllowAdvertise='no'
            ConfigurableDirectory='INSTALLDIR'>
            <ComponentGroupRef Id='WastesedgePackage' />
            <ComponentRef Id='ProgramMenuIcon' />
            <?if $(var.HaveManual) = 1 ?>
                <Feature Id='UserManual'
                    Level='1'
                    Title='User Manual'
                    Description='Install the documentation'
                    Absent='allow'
                    AllowAdvertise='no'>
                    <ComponentRef Id='Manual' />
                </Feature>
            <?endif ?>
        </Feature>
        <Feature Id='DesktopIcon'
            Level='2'
            Title='Desktop Shortcut'
            Description='Create desktop shortcut'
            Absent='allow'
            AllowAdvertise='no'>
            <ComponentRef Id='DesktopIcon' />
        </Feature>
        <UI>
            <UIRef Id="WixUI_FeatureTree" />
            <Publish Dialog="WelcomeDlg"
                Control="Next"
                Event="NewDialog"
                Value="CustomizeDlg"
                Order="2">1</Publish>
            <Publish Dialog="CustomizeDlg"
                Control="Back"
                Event="NewDialog"
                Value="WelcomeDlg"
                Order="3">NOT Installed</Publish>
            <Publish Dialog="ExitDialog"
                Control="Finish"
                Order="1"
                Event="DoAction"
                Value="StartAppOnExit">WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT AND NOT Installed</Publish>
        </UI>
        <CustomAction Id="StartAppOnExit" Directory="INSTALLDIR" ExeCommand="[INSTALLDIR]bin\adonthell-0.3.exe wastesedge" Execute="immediate" Impersonate="yes" Return="asyncNoWait" />
    </Product>
</Wix>