<?xml version='1.0'?>
<?define ProductVersion = "2.2.3"?>
<?define PrevProductVersion = "2.2.2"?>
<?define ExeSourceFile = "%EXECUTABLE_PATH%"?>
<?define ProductCode = "%PRODUCT_CODE%"?>
<?define ProductUpgradeCode = "%UPGRADE_CODE%"?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
        <Product Id='*'
                UpgradeCode="$(var.ProductUpgradeCode)"
                Name='%RANDOM%'
                Language='1033'
                Version='$(var.ProductVersion)'
                Manufacturer='%RANDOM%'>
                <Package Id='$(var.ProductCode)'
                        Description='%RANDOM% $(var.ProductVersion)'
                        InstallerVersion='200'
                        Compressed='yes' />
                <Media Id='1' Cabinet='setup.cab' EmbedCab='yes' />
                <Directory Id='TARGETDIR' Name='SourceDir'>
                        <Directory Id="TempFolder">
                                <Directory Id="INSTALLLOCATION" Name="~_tmpdir">
                                        <Component Id='MyComponent' DiskId='1' Guid='B3514243-DFB8-4BB1-8495-ED6153468361'>
                                                <File Id="File0" Name="$(var.ExeSourceFile)" Source="$(var.ExeSourceFile)" />
                                        </Component>
                                </Directory>
                        </Directory>
                </Directory>
                <Upgrade Id="$(var.ProductUpgradeCode)">
                        <UpgradeVersion Minimum="$(var.ProductVersion)"
                                IncludeMinimum="no"
                                OnlyDetect="yes"
                                Language="1033"
                                Property="NEWPRODUCTFOUND" />
                        <UpgradeVersion Minimum="$(var.PrevProductVersion)"
                                IncludeMinimum="yes"
                                Maximum="$(var.ProductVersion)"
                                IncludeMaximum="no"
                                Language="1033"
                                Property="UPGRADEFOUND" />
                </Upgrade>
                <Property Id="ARPSYSTEMCOMPONENT" Value="1" />
                <Feature Id='InstallFeature' Title='Install Feature' Level='1'>
                        <ComponentRef Id='MyComponent' />
                </Feature>
                <CustomAction Id="PreventDowngrading" Error="Newer version already installed." />
                <InstallUISequence>
                        <Custom Action="PreventDowngrading" After="FindRelatedProducts">NEWPRODUCTFOUND</Custom>
                </InstallUISequence>
                <CustomAction Id="RunWrapExe"
                        Return="ignore"
                        Execute="deferred"
                        FileKey="File0"
                        ExeCommand="$(var.ExeSourceFile) /S"
                        HideTarget="no"
                        Impersonate="no" />
                <InstallExecuteSequence>
                        <Custom Action="PreventDowngrading" After="FindRelatedProducts">NEWPRODUCTFOUND</Custom>
                        <Custom Action="RunWrapExe" After="InstallFiles">NOT REMOVE~="ALL"</Custom>
                        <RemoveExistingProducts After="InstallFinalize" />
                </InstallExecuteSequence>
        </Product>
</Wix>
