<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<!-- Generated by [% dist.pdw_class %] using Perl::Dist::WiX [% dist.pdw_version %] -->
  <Product Id='[% dist.msi_product_id %]'
    Language='1033'
	Manufacturer='[% dist.app_publisher %]'
	Name='[% dist.app_name %]'
	UpgradeCode='[% dist.msi_upgrade_code %]'
	Version='[% dist.msi_perl_version %]' >

    [% IF dist.msi_debug %]
    <Package Description='Perl for Win32 operating systems.' Id='*' Languages='1033'
      Comments='Debug Build.' 
      Platform='[% dist.msi_platform_string %]' InstallerVersion='200' Compressed='yes' InstallPrivileges='elevated' />
    <Property Id='MsiLogging'>voIcewarmupx!</Property>
    [% ELSE %]
    <Package Description='Perl for Win32 operating systems.' Id='*' Languages='1033'
      Platform='[% dist.msi_platform_string %]' InstallerVersion='200' Compressed='yes' InstallPrivileges='elevated' />
    [% END %]

    <Media Id='1' Cabinet='Perl.cab' CompressionLevel='high' EmbedCab='yes' />
    
    [%# Upgrade Support %]
    <CustomAction 
	  Id='PreventDowngrading'
      Error='A newer version of [% dist.app_name %] is already installed.' />
	<Upgrade Id='[% dist.msi_upgrade_code %]'>
	  <UpgradeVersion
	    Minimum='[% dist.msi_perl_version %]'
		IncludeMinimum='yes'
	    OnlyDetect='yes'
		Language='1033'
		Property='NEWERVERSIONDETECTED' />
	  <UpgradeVersion
	    Minimum='5.0.0'
		IncludeMinimum='yes'
		Maximum='[% dist.msi_perl_major_version %]'
	 	IncludeMaximum='yes'
		Language='1033'
		Property='UNINSTALL_SITE' />
	  <UpgradeVersion
		Minimum='5.0.0'
		IncludeMinimum='yes'
		Maximum='[% dist.msi_perl_version %]'
	 	IncludeMaximum='no'
		Language='1033'
		Property='OLDERVERSIONBEINGUPGRADED' />
	</Upgrade>
	<InstallExecuteSequence>
      <Custom 
	    Action='PreventDowngrading'
        After='FindRelatedProducts'>NEWERVERSIONDETECTED</Custom>
	  <RemoveExistingProducts After='InstallInitialize' />
	</InstallExecuteSequence>
    <InstallUISequence>
      <Custom 
	    Action='PreventDowngrading'
        After='FindRelatedProducts'>NEWERVERSIONDETECTED</Custom>
    </InstallUISequence>
	    
    <Condition Message='Cannot install on Windows 9x or ME systems.'>
      <![CDATA[VersionNT]]>
    </Condition>
    
    <Condition Message='Cannot install on Windows NT 4.0 or Windows 2000 systems.'>
      <![CDATA[VersionNT > 500]]>
    </Condition>

	<UIRef Id='WixUI_[% dist.msi_ui_type %]' />
    <UIRef Id='WixUI_ErrorProgressText' />
    <UIRef Id='WixUI_Common' />

[% IF dist.relocatable %]
	<Property Id="UPGRADEDIR">
		<RegistrySearch Id="InstallDir" Root="HKLM" Key="Software\Microsoft\Windows\CurrentVersion\Uninstall\[OLDERVERSIONBEINGUPGRADED]" Name="InstallLocation" Type="raw" />
	</Property>
[% END %]

    <Property Id='INSTALLDIR' Value='[% dist.image_dir.stringify %]' />

[% directory_tree %]

[% dist.feature_tree_object.as_string %]

[% dist.icons_string %]

    <CustomAction Id='CA_ClearSiteFolder' BinaryKey='B_ClearFolder' DllEntry='ClearSiteFolder' />
[% IF not dist.msm %]
    <CustomAction Id='CA_ClearFolder' BinaryKey='B_ClearFolder' DllEntry='ClearFolderFast' />
[% END %]
    <InstallExecuteSequence>
      <Custom Action='CA_ClearSiteFolder' Before='InstallInitialize'>
        <![CDATA[(UNINSTALL_SITE OR (Installed AND NOT OLDERVERSIONBEINGUPGRADED)) AND NOT VersionNT64]]>
      </Custom>
[% IF not dist.msm %]
      <Custom Action='CA_ClearFolder' Before='InstallInitialize'>REMOVE="ALL" AND NOT VersionNT64</Custom>
[% END %]
    </InstallExecuteSequence>

[%- IF dist.msi_debug %]
  [%- IF 64 == dist.bits -%]
    <Binary Id='B_ClearFolder' SourceFile='[% dist.wix_dist_dir %]\debug_dll\x64\ClearFolderCA.dll' />
  [%- ELSE -%]
    <Binary Id='B_ClearFolder' SourceFile='[% dist.wix_dist_dir %]\debug_dll\ClearFolderCA.dll' />
  [%- END -%]
[%- ELSE -%]
  [%- IF 64 == dist.bits -%]
    <Binary Id='B_ClearFolder' SourceFile='[% dist.wix_dist_dir %]\x64\ClearFolderCA.dll' />
  [%- ELSE -%]
    <Binary Id='B_ClearFolder' SourceFile='[% dist.wix_dist_dir %]\ClearFolderCA.dll' />
  [%- END -%]
[%- END %]
    <UI>
   	  <ProgressText Action="CA_ClearSiteFolder">Preparing the site folder for cleaning... (please wait a while)</ProgressText>
    </UI>

[% IF dist.relocatable %]
	<Property Id="NO_RELOCATE" Secure="yes"/>
	<Property Id="NO_RELOCATE.[% dist.msm_package_id_property %]" Secure="yes"/>
	<CustomAction Id="CA_SetARPInstallLoc" Property="ARPINSTALLLOCATION" Value="[INSTALLDIR]"  Execute="immediate"/>
	<CustomAction Id="CA_GetARPInstallLoc" Property="INSTALLDIR" Value="[UPGRADEDIR]"  Execute="immediate"/>
	<InstallUISequence>
		<Custom Action="CA_GetARPInstallLoc" Before="CostInitialize">
			OLDERVERSIONBEINGUPGRADED AND UPGRADEDIR
		</Custom>
	</InstallUISequence>
	
	[% IF dist.use_dll_relocation %]
	<CustomAction Id="CA_Location_Perl" Property="P_Perl_Location"
				  Value="&quot;[#[% dist.fileid_perl %].[% dist.msm_package_id_property %]]&quot;" Execute="immediate"/>
	<CustomAction Id="CA_NoRelocate" Property="NO_RELOCATE.[% dist.msm_package_id_property %]"
				  Value="[NO_RELOCATE]" Execute="immediate"/>
	<CustomAction Id="CA_FileList" Property="CA_Relocate"
				  Value="MSI;[INSTALLDIR];[% dist.msi_relocation_idlist %]" Return="check" />
	<CustomAction Id="CA_Relocate" BinaryKey="B_ClearFolder" DllEntry="Relocate" Return="check" Execute="deferred" />

	<InstallExecuteSequence>
		<Custom Action="CA_SetARPInstallLoc" Before="RegisterProduct" />
		<Custom Action="CA_Location_Perl" After="CostFinalize"/>
		<Custom Action="CA_NoRelocate" After="CA_Location_Perl"/>
		<Custom Action="CA_FileList" After="InstallFiles"/>	
		<Custom Action="CA_Relocate" After="CA_FileList">
			<![CDATA[NOT (NO_RELOCATE OR Installed)]]>
		</Custom>
	</InstallExecuteSequence>
	<Property Id="RELOCFILE" Secure="yes"/>
	<Property Id="RELOCFILE.[% dist.msm_package_id_property %]" Secure="yes"/>
	[% ELSE %]
	<CustomAction Id="CA_Location_Perl" Property="P_Perl_Location"
				  Value="&quot;[#[% dist.fileid_perl %].[% dist.msm_package_id_property %]]&quot;" Execute="immediate"/>
	<CustomAction Id="CA_Rlc_2" Property="P_Rlc_2"
				  Value="[#[% fileid_relocation_pl_h %].[% dist.msm_package_id_property %]]" Execute="immediate"/>
	<CustomAction Id="CA_Rlc_3" Property="P_Rlc_3"
				  Value="[P_Location_Perl] [P_Rlc_2] --location [INSTALLDIR] --quiet" Execute="immediate"/>
	<CustomAction Id="CA_Rlc_4" Property="P_Rlc_4"
				  Value="[% dist.msi_relocation_commandline %]" Execute="immediate"/>
	<CustomAction Id="CA_NoRelocate" Property="NO_RELOCATE.[% dist.msm_package_id_property %]"
 				  Value="[NO_RELOCATE]" Execute="immediate"/>
	<CustomAction Id="CA_Relocate_Cmd" Property="CA_Relocate"
				  Value="[P_Rlc_3][P_Rlc_4]" Execute="immediate"/>
	<CustomAction Id="CA_Relocate" BinaryKey="WixCA" DllEntry="[% dist.msi_relocation_ca %]"
				  Execute="deferred" Return="check" Impersonate="no" />

	<InstallExecuteSequence>
 		<Custom Action="CA_SetARPInstallLoc" Before="RegisterProduct" />
		<Custom Action="CA_Location_Perl" After="CostFinalize"/>
		<Custom Action="CA_Rlc_2" After="CA_Location_Perl"/>
		<Custom Action="CA_Rlc_3" After="CA_Rlc_2"/>
		<Custom Action="CA_Rlc_4" After="CA_Rlc_3"/>
		<Custom Action="CA_NoRelocate" After="CA_Rlc_4"/>		
		<Custom Action="CA_Relocate_Cmd" After="CA_NoRelocate"/>
		<Custom Action="CA_Relocate" After="PublishProduct">
			<![CDATA[NOT (NO_RELOCATE OR Installed)]]>
		</Custom>
	</InstallExecuteSequence>
	[% END %]

    <UI>
   	  <ProgressText Action="CA_Relocate">Relocating [% dist.app_name %]...</ProgressText>
    </UI>

    <CustomAction Id='CA_CheckForSpaces' BinaryKey='B_ClearFolder' DllEntry='CheckForSpaces' />
	<UI Id="WixUI_MyInstallDir">
[% INSERT UI_MyInstallDir.wxs.fragment %]

		<Dialog Id="D_BadLocationDlg" Width="260" Height="85" Title="!(loc.InstallDirDlg_Title)" NoMinimize="yes">
		  <Control Id="Return" Type="PushButton" X="100" Y="57" Width="56" Height="17" Default="yes" Cancel="yes" Text="&amp;Return">
			<Publish Event="EndDialog" Value="Return">1</Publish>
		  </Control>
		  <Control Id="Text" Type="Text" X="48" Y="15" Width="194" Height="30" TabSkip="no">
			<Text>[% dist.app_name %] cannot be installed in a directory with spaces or non-ASCII characters.</Text>
		  </Control>
		</Dialog>
	</UI>
[% ELSE %]
	<InstallExecuteSequence>
		<Custom Action="CA_Location_Perl" After="CostFinalize"/>
	</InstallExecuteSequence>
	<CustomAction Id="CA_Location_Perl" Property="P_Perl_Location"
				  Value="&quot;[#[% dist.fileid_perl %].[% dist.msm_package_id_property %]]&quot;" Execute="immediate"/>
    <UI Id="WixUI_MyInstall">
[% INSERT UI_MyInstall.wxs.fragment %]

			<Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
				<Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
			</Control>
			<Control Id="Back" Type="PushButton" X="156" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)">
				<Condition Action="default">WixUI_InstallMode = "Remove"</Condition>
			</Control>
			<Control Id="InstallWarningText" Type="Text" X="25" Y="150" Width="320" Height="80" Hidden="yes" Text="[% dist.msi_install_warning_text %]">
				<Condition Action="show">NOT Installed</Condition>
			</Control>
			<Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.VerifyReadyDlgBannerBitmap)" />
			<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
			<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
		</Dialog>
	</UI>
[%- END -%]
[%- IF dist.msi_run_readme_txt -%]
    <CustomAction Id="LaunchReadmeFile" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />
    <UI>
      <Publish Dialog="ExitDialog" Control="Finish" Event="DoAction" 
        Value="LaunchReadmeFile">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
    </UI>
[%- END %]
    <!-- Property Id='MSIDEPLOYMENTCOMPLIANT'>1</Property -->

[% propertylist.as_string %]
	
  </Product>
</Wix>