<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
 xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
  <?if "$(var.MgPlatform)" = "x64" ?>
  <?define Win64 = "yes" ?>
  <?define PlatformProgramFilesFolder = "ProgramFiles64Folder" ?>
  <?else ?>
  <?define Win64 = "no" ?>
  <?define PlatformProgramFilesFolder = "ProgramFilesFolder" ?>
  <?endif ?>
  <Fragment>
    <DirectoryRef Id="ProgramMenuFolder">
      <!-- HACK: For some reason the MG_VERSION_MAJOR_MINOR property doesn't evaluate, so hardcode it for now -->
      <Directory Id="MapGuideOpenSourceMenuLocation" Name="MapGuide Open Source 4.0">
        <Component Id="GenericShortcutComponent" Win64="$(var.Win64)" Guid="243CE0F3-D6BC-476B-910E-6F34DA54A2E2">
          <CreateFolder />
          <RegistryKey Root="HKCU" Key="$(var.MgRegKey)\GenericShortcut">
            <RegistryValue
              Value="Installed"
              Type="string"
              KeyPath="yes" />
          </RegistryKey>
          <RemoveFolder Id="MapGuideOpenSourceMenuLocation" On="uninstall" />
        </Component>
        <Component Id="ApacheWebApiShortcutComponent" Win64="$(var.Win64)" Guid="5FC3FEA9-4DCD-404A-8835-43C8C2F96E29">
          <Condition>MGWEB_CONFIG=&quot;APACHE&quot;</Condition>
          <CreateFolder />
          <util:InternetShortcut Id="ApacheWebApi"
           Directory="MapGuideOpenSourceMenuLocation"
           Name="!(loc.Shortcut_WebAPI)"
           Target="http://localhost:[APACHE_PORT]/[VIRTUALDIR]/help/webapi/index.htm" />
          <RegistryKey Root="HKCU" Key="$(var.MgRegKey)\ApacheWebApiShortcut">
            <RegistryValue
              Value="Installed"
              Type="string"
              KeyPath="yes" />
          </RegistryKey>
        </Component>
        <Component Id="ApacheDevGuideShortcutComponent" Win64="$(var.Win64)" Guid="4DC72C73-8CF0-49B3-8558-5E7CAFA7B6CE">
          <Condition>MGWEB_CONFIG=&quot;APACHE&quot;</Condition>
          <CreateFolder />
          <util:InternetShortcut Id="ApacheDevGuide"
           Directory="MapGuideOpenSourceMenuLocation"
           Name="!(loc.Shortcut_DevGuide)"
           Target="http://localhost:[APACHE_PORT]/[VIRTUALDIR]/help/devguide/index.html" />
          <RegistryKey Root="HKCU" Key="$(var.MgRegKey)\ApacheDevGuideShortcut">
            <RegistryValue
              Value="Installed"
              Type="string"
              KeyPath="yes" />
          </RegistryKey>
        </Component>
        <Component Id="ApacheViewerApiShortcutComponent" Win64="$(var.Win64)" Guid="47CD50F1-5961-43F8-8FE8-BF1CDC8AE895">
          <Condition>MGWEB_CONFIG=&quot;APACHE&quot;</Condition>
          <CreateFolder />
          <util:InternetShortcut Id="ApacheViewerApi"
           Directory="MapGuideOpenSourceMenuLocation"
           Name="!(loc.Shortcut_ViewerAPI)"
           Target="http://localhost:[APACHE_PORT]/[VIRTUALDIR]/help/viewerapi/index.htm" />
          <RegistryKey Root="HKCU" Key="$(var.MgRegKey)\ApacheViewerApiShortcut">
            <RegistryValue
              Value="Installed"
              Type="string"
              KeyPath="yes" />
          </RegistryKey>
        </Component>
        <Component Id="ApacheFusionApiShortcutComponent" Win64="$(var.Win64)" Guid="4AABF916-33FC-440D-9D6F-8CE95F2ADE7A">
          <Condition>MGWEB_CONFIG=&quot;APACHE&quot;</Condition>
          <CreateFolder />
          <util:InternetShortcut Id="ApacheFusionApi"
           Directory="MapGuideOpenSourceMenuLocation"
           Name="!(loc.Shortcut_FusionAPI)"
           Target="http://localhost:[APACHE_PORT]/[VIRTUALDIR]/fusion/docs/NaturalDocs/index.html" />
          <RegistryKey Root="HKCU" Key="$(var.MgRegKey)\ApacheFusionApiShortcut">
            <RegistryValue
              Value="Installed"
              Type="string"
              KeyPath="yes" />
          </RegistryKey>
        </Component>
        <Component Id="WebApacheShortcutComponent" Win64="$(var.Win64)" Guid="2EBC8176-07C5-40A9-97F9-C3E83836637E">
          <Condition>MGWEB_CONFIG=&quot;APACHE&quot;</Condition>
          <util:InternetShortcut Id="ApacheSiteAdmin"
           Directory="MapGuideOpenSourceMenuLocation"
           Name="!(loc.Shortcut_SiteAdmin)"
           Target="http://localhost:[APACHE_PORT]/[VIRTUALDIR]/mapadmin/login.php" />
          <util:InternetShortcut Id="ApacheGetMaestro"
            Directory="MapGuideOpenSourceMenuLocation"
            Name="!(loc.Shortcut_GetMaestro)"
            Target="http://trac.osgeo.org/mapguide/wiki/maestro" />
          <RegistryKey Root="HKCU" Key="$(var.MgRegKey)\ApacheShortcut">
            <RegistryValue
              Value="Installed"
              Type="string"
              KeyPath="yes" />
          </RegistryKey>
        </Component>
        <Component Id="WebApacheMapAgentShortcutComponent" Win64="$(var.Win64)" Guid="BB57DB3F-73E3-4DAD-8899-33A4DC398579">
          <Condition>MGWEB_CONFIG=&quot;APACHE&quot;</Condition>
          <util:InternetShortcut Id="ApacheMapAgent"
            Directory="MapGuideOpenSourceMenuLocation"
            Name="!(loc.Shortcut_MapAgent)"
            Target="http://localhost:[APACHE_PORT]/[VIRTUALDIR]/mapagent/index.html" />
          <RegistryKey Root="HKCU" Key="$(var.MgRegKey)\ApacheMapAgentShortcut">
            <RegistryValue
              Value="Installed"
              Type="string"
              KeyPath="yes" />
          </RegistryKey>
        </Component>
        <Component Id="WebApacheSampleShortcutComponent" Win64="$(var.Win64)" Guid="E3D81381-6B4A-41AD-B83A-CE686455D3DC">
          <Condition>MGWEB_CONFIG=&quot;APACHE&quot;</Condition>
          <util:InternetShortcut Id="ApacheSamplesShortcut"
           Directory="MapGuideOpenSourceMenuLocation"
           Name="!(loc.Shortcut_Samples)"
           Target="http://localhost:[APACHE_PORT]/[VIRTUALDIR]/samples.php" />
          <RegistryKey Root="HKCU" Key="$(var.MgRegKey)\ApacheSamplesShortcutComponent">
            <RegistryValue
              Value="Installed"
              Type="string"
              KeyPath="yes" />
          </RegistryKey>
        </Component>
        <Component Id="IISWebApiShortcutComponent" Win64="$(var.Win64)" Guid="DFA7D99A-3760-4072-9510-7EC5D658FB5F">
          <Condition>MGWEB_CONFIG=&quot;IIS&quot;</Condition>
          <CreateFolder />
          <util:InternetShortcut Id="IISWebApi"
           Directory="MapGuideOpenSourceMenuLocation"
           Name="!(loc.Shortcut_WebAPI)"
           Target="http://localhost/[VIRTUALDIR]/help/webapi/index.htm" />
          <RegistryKey Root="HKCU" Key="$(var.MgRegKey)\IISWebApiShortcut">
            <RegistryValue
              Value="Installed"
              Type="string"
              KeyPath="yes" />
          </RegistryKey>
        </Component>
        <Component Id="IISDevGuideShortcutComponent" Win64="$(var.Win64)" Guid="BA2B2FE0-F11E-41D0-9939-D774C1D3171A">
          <Condition>MGWEB_CONFIG=&quot;IIS&quot;</Condition>
          <CreateFolder />
          <util:InternetShortcut Id="IISDevGuide"
           Directory="MapGuideOpenSourceMenuLocation"
           Name="!(loc.Shortcut_DevGuide)"
           Target="http://localhost/[VIRTUALDIR]/help/devguide/index.html" />
          <RegistryKey Root="HKCU" Key="$(var.MgRegKey)\IISDevGuideShortcut">
            <RegistryValue
              Value="Installed"
              Type="string"
              KeyPath="yes" />
          </RegistryKey>
        </Component>
        <Component Id="IISViewerApiShortcutComponent" Win64="$(var.Win64)" Guid="F2CCA279-4C99-48CE-9F79-7465449E2B33">
          <Condition>MGWEB_CONFIG=&quot;IIS&quot;</Condition>
          <CreateFolder />
          <util:InternetShortcut Id="IISViewerApi"
           Directory="MapGuideOpenSourceMenuLocation"
           Name="!(loc.Shortcut_ViewerAPI)"
           Target="http://localhost/[VIRTUALDIR]/help/viewerapi/index.htm" />
          <RegistryKey Root="HKCU" Key="$(var.MgRegKey)\IISViewerApiShortcut">
            <RegistryValue
              Value="Installed"
              Type="string"
              KeyPath="yes" />
          </RegistryKey>
        </Component>
        <Component Id="IISFusionApiShortcutComponent" Win64="$(var.Win64)" Guid="8F4A6B97-DEFB-4AA1-859E-3392C5DC30D2">
          <Condition>MGWEB_CONFIG=&quot;IIS&quot;</Condition>
          <CreateFolder />
          <util:InternetShortcut Id="IISFusionApi"
           Directory="MapGuideOpenSourceMenuLocation"
           Name="!(loc.Shortcut_FusionAPI)"
           Target="http://localhost/[VIRTUALDIR]/fusion/docs/NaturalDocs/index.html" />
          <RegistryKey Root="HKCU" Key="$(var.MgRegKey)\IISFusionApiShortcut">
            <RegistryValue
              Value="Installed"
              Type="string"
              KeyPath="yes" />
          </RegistryKey>
        </Component>
        <Component Id="WebIISSamplesShortcutComponent" Win64="$(var.Win64)" Guid="F1B2C345-52F8-4179-8CDC-34D2D3E22418">
          <Condition>MGWEB_CONFIG=&quot;IIS&quot;</Condition>
          <util:InternetShortcut Id="IISSamplesShortcut"
           Directory="MapGuideOpenSourceMenuLocation"
           Name="!(loc.Shortcut_Samples)"
           Target="http://localhost/[VIRTUALDIR]/samples.php" />
          <RegistryKey Root="HKCU" Key="$(var.MgRegKey)\IISSamplesShortcutComponent">
            <RegistryValue
              Value="Installed"
              Type="string"
              KeyPath="yes" />
          </RegistryKey>
        </Component>
        <Component Id="WebIISShortcutComponent" Win64="$(var.Win64)" Guid="F59A450A-84DE-4E2E-B942-BD416CDEBBF3">
          <Condition>MGWEB_CONFIG=&quot;IIS&quot;</Condition>
          <util:InternetShortcut Id="IISSiteAdmin"
           Directory="MapGuideOpenSourceMenuLocation"
           Name="!(loc.Shortcut_SiteAdmin)"
           Target="http://localhost/[VIRTUALDIR]/mapadmin/login.php" />
          <util:InternetShortcut Id="IISGetMaestro"
            Directory="MapGuideOpenSourceMenuLocation"
            Name="!(loc.Shortcut_GetMaestro)"
            Target="http://trac.osgeo.org/mapguide/wiki/maestro" />
          <RegistryKey Root="HKCU" Key="$(var.MgRegKey)\IISShortcut">
            <RegistryValue
              Value="Installed"
              Type="string"
              KeyPath="yes" />
          </RegistryKey>
        </Component>
        <Component Id="WebIISMapAgentShortcutComponent" Win64="$(var.Win64)" Guid="BEB5E02C-8D04-46FB-91E4-6EDB033414F3">
          <Condition>MGWEB_CONFIG=&quot;IIS&quot;</Condition>
          <util:InternetShortcut Id="IISMapAgent"
            Directory="MapGuideOpenSourceMenuLocation"
            Name="!(loc.Shortcut_MapAgent)"
            Target="http://localhost/[VIRTUALDIR]/mapagent/index.html" />
          <RegistryKey Root="HKCU" Key="$(var.MgRegKey)\IISMapAgentShortcut">
            <RegistryValue
              Value="Installed"
              Type="string"
              KeyPath="yes" />
          </RegistryKey>
        </Component>
        <Component Id="DevHttpServerShortcutComponent" Win64="$(var.Win64)" Guid="3517d6df-a723-4fb0-ac21-5b5de3a5cff3">
          <!-- 
            HACK: I'd prefer not to use relative paths below, but the variables for the paths in question
            area "owned" by a different component, preventing their use here
          -->
          <Shortcut Id="DevHttpServerShortcut" 
                  Name="!(loc.Shortcut_DevHttpServer)"
                  Target="[#DEV_HTTP_SERVER_EXE]"
                  Arguments="-p 8028 -r ..\www -w ..\www\webconfig.ini"
                  WorkingDirectory="DEVHTTPSERVERLOCATION"/>
          <RegistryValue Root="HKCU" Key="$(var.MgRegKey)\DevHttpServerShortcut" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
        </Component>
        <Directory Id="WebResourcesLocation" Name="Web Resources">
          <Component Id="WebShortcutsComponent" Win64="$(var.Win64)" Guid="7D2E24E9-533B-4119-A6D1-E48A33BF34C3">
            <CreateFolder />
            <util:InternetShortcut Id="MapGuideHome"
             Directory="WebResourcesLocation"
             Name="!(loc.Shortcut_MapGuide)"
             Target="http://mapguide.osgeo.org" />
            <util:InternetShortcut Id="MapGuideTrac"
              Directory="WebResourcesLocation"
              Name="!(loc.Shortcut_Trac)"
              Target="http://trac.osgeo.org/mapguide" />
            <util:InternetShortcut Id="AutodeskWikiHelp"
              Directory="WebResourcesLocation"
              Name="!(loc.Shortcut_WikiHelp)"
              Target="http://help.autodesk.com/view/AIMS/2017/ENU/" />
            <RegistryKey Root="HKCU" Key="$(var.MgRegKey)\ProgramMenuShortcut">
              <RegistryValue
                Value="Installed"
                Type="string"
                KeyPath="yes" />
            </RegistryKey>
            <RemoveFolder Id="WebShortcutsComponent" On="uninstall" />
          </Component>
        </Directory>
      </Directory>
    </DirectoryRef>
  </Fragment>
</Wix>