<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
	<Product Id="*" Name="Advertising Profit Control" Language="1033" Version="2.0.2.20" Manufacturer="Garritt McCune" UpgradeCode="a416a558-d7c0-4f24-8b1e-2d01761ad15f">
		<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Description="Custom Profit Control Recording Software" Comments="Profit Control Recording Software"/>
		<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
    <!--Not set by default, EmbedCab="yes" embeds the cabinet file into the installer-->
		<MediaTemplate EmbedCab="yes"/>
    <!--Set the program's icon-->
    <Icon Id="icon.ico" SourceFile="$(var.SolutionDir)\AdvertsingProfitControl\Stretched Logo Collection.ico"/>
    <Property Id="ARPPRODUCTICON" Value="icon.ico" />
    <!--Displays the installer so the user can choose what directory they'd like to install the product.-->
    <!--There are no select features options with this install dialog.-->
    <Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
    <UI>
      <UIRef Id="WixUI_InstallDir" />

      <!-- Skip license dialog -->
      <Publish Dialog="WelcomeDlg"
               Control="Next"
               Event="NewDialog"
               Value="InstallDirDlg"
               Order="2">1</Publish>
      <Publish Dialog="InstallDirDlg"
               Control="Back"
               Event="NewDialog"
               Value="WelcomeDlg"
               Order="2">1</Publish>
    </UI>
    <!--Try to detect SQL Server.-->
    <Property Id="SQLSERVER_INSTANCE">
      <RegistrySearch Id="SQLServerRegSearch" Root="HKLM" Key="SOFTWARE\Microsoft\Microsoft Sql Server\Instance Names\SQL" Type="raw" Name="SQLEXPRESS" Win64="yes"/>
          <RegistrySearch Id="SQLServerRegSearch32" Root="HKLM" Key="SOFTWARE\Microsoft\Microsoft Sql Server\Instance Names\SQL" Type="raw" Name="SQLEXPRESS" Win64="no"/>
    </Property>
    <Condition Message="SQL Server 2016 is required to use [ProductName]. Please install SQL Server 2016 then run this installer again.">
      <![CDATA[SQLSERVER_INSTANCE]]>
    </Condition>
    <!--Detect .NET Framework 4.5-->
    <PropertyRef Id="NETFRAMEWORK45"/>

    <Condition Message="[ProductName] requires .NET Framework 4.5. Please install the .NET Framework then run this installer again.">
        <![CDATA[Installed OR NETFRAMEWORK45]]>
    </Condition>
    <!--Define the icons used in the installer dialogs-->
    <WixVariable Id="WixUILicenseRtf" Value="License.rtf" />
    <WixVariable Id="WixUIBannerBmp" Value="Banner.bmp" />
    <WixVariable Id="WixUIDialogBmp" Value="Dialog.bmp" />
		<Feature Id="ProductFeature" Title="AdvertisingProfitControl" Level="1">
			<ComponentGroupRef Id="ProductComponents" />
      <ComponentRef Id="ApplicationShortcut" /> 
		</Feature>
	</Product>    
  
	<Fragment>
    <!--Install Directory-->
		<Directory Id="TARGETDIR" Name="SourceDir">
			<Directory Id="ProgramFilesFolder">
				<Directory Id="INSTALLFOLDER" Name="Advertising Profit Control" />
			</Directory>
      <!--Define shortcut-->
      <Directory Id="ProgramMenuFolder">
        <Directory Id="ApplicationProgramsFolder" Name="Advertising Profit Control"/>
      </Directory>
     <!--App data folder-->
      <!--<Directory Id="LocalAppDataFolder">
        <Directory Id="LoggingFolder" Name="APC" />    
      </Directory>    -->
		</Directory>
	</Fragment>
 <!--Define the shortcut-->
  <Fragment>
    <DirectoryRef Id="ApplicationProgramsFolder">
      <Component Id="ApplicationShortcut" Guid="*">
          <Shortcut Id="ApplicationStartMenuShortcut" 
                    Name="Advertising Profit Control"
                    Description="Profit Control Recording Software"
                    Target="[#AdvertsingProfitControl.exe]"
                    WorkingDirectory="APPLICATIONROOTDIRECTORY"/>
          <RemoveFolder Id="CleanUpShortCut" Directory="ApplicationProgramsFolder" On="uninstall"/>
          <RegistryValue Root="HKCU" Key="Software\Microsoft\AdvertsingProfitControl" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
      </Component>
    </DirectoryRef>
  </Fragment>
  
	<Fragment>
		<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
			<Component Id="AdvertisingProfitControl.exe">
      <File Source="$(var.AdvertsingProfitControl.TargetPath)" />
		  </Component>
      <!--Mark all needed DLLs and configuration files to be installed in the directory with the main binary.-->
      <Component Id="AppConfig">
        <File Name="AdvertsingProfitControl.exe.config" Source="$(var.SolutionDir)\AdvertsingProfitControl\App.config"/>
      </Component>
      <Component Id="HTMLRender">
              <File Source="$(var.SolutionDir)\packages\HtmlRenderer.WinForms.1.5.0.6\lib\net45\HtmlRenderer.WinForms.dll"/>
      </Component>
            <Component Id="HTMLRenderCore">
              <File Source="$(var.SolutionDir)\packages\HtmlRenderer.Core.1.5.0.6\lib\net45\HtmlRenderer.dll"/>
      </Component>
          <Component Id="EntityFrameworkDll">
              <File Source="$(var.SolutionDir)\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll"/>
      </Component>
      <Component Id="EntityFrameworkSqlDll">
              <File Source="$(var.SolutionDir)\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll"/>
      </Component>
		</ComponentGroup>
	</Fragment>
</Wix>
