<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

  <!-- SECTION A - Package definitions and checks -->
  
  <Product Id="*" Name="SimpleEAMenuInstaller" Language="1033" Version="1.0.0.0" Manufacturer="EXploringEA" UpgradeCode=YOUR-UPDGRADE-4EA9-80C1-EEFC5473F3CE">
    <Package InstallerVersion="500" Description ="This is the Simple Addin Installer" Compressed="yes" InstallScope="perUser" />
    <!-- The following line prevents downgrade-->
		<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
    <Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />
    
    <!-- SECTION B - set per User -->
    <!-- The following properties specify that the installation is Per User -->
    <Property Id="ALLUSERS" Secure="yes" Value="2"/>
    <Property Id="MSIINSTALLPERUSER" Secure="yes" Value="1" />
    <!-- END SECTION B -->
    <!-- SECTION C - installation directory structure --> 
    <Directory Id='TARGETDIR' Name='SourceDir'>
      <Directory Id='ProgramFilesFolder' Name='PFiles'> <!-- This is the root of the program files  for Per User it is ..\Appdata\Local\Programs -->
        <Directory Id='AddIn' Name='EXploringEAAddins'>
          <Directory Id='INSTALLDIR' Name='SimpleAddIn'>

            <!-- SECTION D - package components -->
            <!-- This creates and removes the install folder at thr INSTALLDIR location -->
            <Component Id="InstallFolder" Guid="YOUR-GUID1-442D-A0F8-E48F0AC4BDFD" KeyPath="yes"> 
              <CreateFolder />
              <RemoveFile Id="PurgeAppFolder" Name="*.*" On="uninstall" />
            </Component>
            
            <!-- This adds and removes our Sparx AddIn key -->
            <Component Id="Sparx" Guid ="YOUR-GUID2-4BE0-86B8-875E413E021E" >
              <RegistryKey Root="HKCU" Key="Software\Sparx Systems\EAAddins\NameOfSimpleAddIn" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes"> <!-- Name of my key-->
                <RegistryValue Type="string" Value="ASimpleAddin.ASimpleEAMenu" KeyPath="yes" /> <!-- This is the class name that Sparx will look for -->
              </RegistryKey>
              <RemoveRegistryKey Id='SparxKey' Root="HKCU" Key='Software\Sparx Systems\EAAddins\NameOfSimpleAddIn' Action="removeOnUninstall"/>
            </Component>
                 
            <!-- We add/remove a key that saves our installed program location (for our use) e.g. we may put other files in that location -->
            <Component Id="ProgramLocation" Guid="YOUR-GUID3-4552-9EA9-164F11839699" > 
              <RegistryKey Root="HKCU" Key="Software\EXploringEA\SimpleAddIn">
                <RegistryValue Type='string' Name='ProgramDir' Value='[INSTALLDIR]' KeyPath="yes"/> <!-- Sets the key ProgramDir to Program directory-->
              </RegistryKey>
              <RemoveRegistryKey Id='ProgLoc' Root="HKCU" Key='Software\EXploringEA\SimpleAddIn' Action="removeOnUninstall"/>
            </Component>
            <!-- END SECTION D -->
            
          </Directory>
          </Directory>
        </Directory>
      </Directory>
    <!-- END SECTION C -->
    
    <!-- SECTION E - package features -->
    <!-- Features define which components are in the package these are defined below-->
		<Feature Id="ProductFeature" Title="SimpleEAMenuInstaller" Level="1">
	    <ComponentGroupRef Id="DLLClasses" />
      <ComponentRef Id="InstallFolder" />
      <ComponentRef Id="Sparx" />
      <ComponentRef Id='ProgramLocation' />
    </Feature>
    <!-- END SECTION E -->
    
	</Product> <!-- End SECTION A -->
 
</Wix>