<?xml version="1.0" ?>
<Wix xmlns='http://schemas.microsoft.com/wix/2003/01/wi'>

  <!--

      External defines:

      Platform : Must be set to Intel, x64 or Intel64 to indicate the target architecture.
      VCVer : 14 or 15.  Corresponds to the version of the VC compiler.
      Config : Retail or Debug.

      -->

  <?ifndef Config?>
    <?define Config=Debug?>
  <?endif?>

  <?ifndef VCVer?>
    <?define VCVer=14?>
  <?endif?>

  <?if $(var.VCVer) = "1400"?>
    <?define VString=8.0?>
    <?define VCU=8_0?>
    <?define VCV=VC80?>
  <?elseif $(var.VCVer) = "1500"?>
    <?define VString=9.0?>
    <?define VCU=9_0?>
    <?define VCV=VC90?>
  <?else?>
    <?error Unknown VCVer value?>
  <?endif?>

    <Product
       Id="????????-????-????-????-????????????"
       Codepage="1252"
       Language="1033"
       Manufacturer="Microsoft Corporation"
       Name="Visual Studio $(var.VString) $(var.Config) ($(var.Platform)) Runtime"
       UpgradeCode="1184DE9F-813A-4DB3-8533-BB7D4E51D695"
       Version="0.1.0.0"
       >
      <Package
         Id="????????-????-????-????-????????????"
         AdminImage="no"
         Comments="Copyright (C) Microsoft Corporation, All rights reserved."
         Compressed="yes"
         Description="Visual C++ $(var.VString) $(var.Config) ($(var.Platform)) WinSXS MSM"
         InstallerVersion="300"
         Keywords="Installer,VC,$(var.Config),Runtime"
         Manufacturer="Microsoft Corporation"
         Platforms="$(var.Platform)"
         ShortNames="no"
         SummaryCodepage="1252"
         />

      <Directory Id="TARGETDIR" Name="SourceDir">
	<?ifdef env.CommonProgramFiles6432?>
	  <?define CPF="$(env.CommonProgramFiles(x86)"?>
	<?else?>
	  <?define CPF="$(env.CommonProgramFiles)"?>
	<?endif?>

	<?if $(var.Platform) = "x64" ?>
	  <?if $(var.Config) = "Retail" ?>
	    <Merge Id="MSVCRTMEM" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\Microsoft_$(var.VCV)_CRT_x86_x64.msm"/>
	    <Merge Id="MSVCRTPOL" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\policy_$(var.VCU)_Microsoft_$(var.VCV)_CRT_x86_x64.msm"/>
	    <Merge Id="MSVCRTMFC" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\Microsoft_$(var.VCV)_MFC_x86_x64.msm"/>
	    <Merge Id="MSVCRTPFC" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\policy_$(var.VCU)_Microsoft_$(var.VCV)_MFC_x86_x64.msm"/>
	    <Merge Id="MSVCRTMFL" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\Microsoft_$(var.VCV)_MFCLOC_x86_x64.msm"/>
	    <Merge Id="MSVCRTPFL" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\policy_$(var.VCU)_Microsoft_$(var.VCV)_MFCLOC_x86_x64.msm"/>
 	  <?else?>
	    <Merge Id="MSVCRTMEM" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\Microsoft_$(var.VCV)_DebugCRT_x86_x64.msm"/>
	    <Merge Id="MSVCRTPOL" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\policy_$(var.VCU)_Microsoft_$(var.VCV)_DebugCRT_x86_x64.msm"/>
	    <Merge Id="MSVCRTMFC" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\Microsoft_$(var.VCV)_DebugMFC_x86_x64.msm"/>
	    <Merge Id="MSVCRTPFC" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\policy_$(var.VCU)_Microsoft_$(var.VCV)_DebugMFC_x86_x64.msm"/>
	    <Merge Id="MSVCRTMFL" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\Microsoft_$(var.VCV)_MFCLOC_x86_x64.msm"/>
	    <Merge Id="MSVCRTPFL" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\policy_$(var.VCU)_Microsoft_$(var.VCV)_MFCLOC_x86_x64.msm"/>
	  <?endif?>
        <?else?>
	  <?if $(var.Config) = "Retail" ?>
	    <Merge Id="MSVCRTMEM" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\Microsoft_$(var.VCV)_CRT_x86.msm"/>
	    <Merge Id="MSVCRTPOL" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\policy_$(var.VCU)_Microsoft_$(var.VCV)_CRT_x86.msm"/>
	    <Merge Id="MSVCRTMFC" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\Microsoft_$(var.VCV)_MFC_x86.msm"/>
	    <Merge Id="MSVCRTPFC" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\policy_$(var.VCU)_Microsoft_$(var.VCV)_MFC_x86.msm"/>
	    <Merge Id="MSVCRTMFL" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\Microsoft_$(var.VCV)_MFCLOC_x86.msm"/>
	    <Merge Id="MSVCRTPFL" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\policy_$(var.VCU)_Microsoft_$(var.VCV)_MFCLOC_x86.msm"/>
	  <?else?>
	    <Merge Id="MSVCRTMEM" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\Microsoft_$(var.VCV)_DebugCRT_x86.msm"/>
	    <Merge Id="MSVCRTPOL" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\policy_$(var.VCU)_Microsoft_$(var.VCV)_DebugCRT_x86.msm"/>
	    <Merge Id="MSVCRTMFC" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\Microsoft_$(var.VCV)_DebugMFC_x86.msm"/>
	    <Merge Id="MSVCRTPFC" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\policy_$(var.VCU)_Microsoft_$(var.VCV)_DebugMFC_x86.msm"/>
	    <Merge Id="MSVCRTMFL" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\Microsoft_$(var.VCV)_MFCLOC_x86.msm"/>
	    <Merge Id="MSVCRTPFL" DiskId="1" Language="0" src="$(var.CPF)\Merge Modules\policy_$(var.VCU)_Microsoft_$(var.VCV)_MFCLOC_x86.msm"/>
	  <?endif?>
	<?endif?>
      </Directory>

      <Feature Id="FeatureAll" AllowAdvertise="no" Absent="disallow"
               Description="Install VC ++ $(var.VString) Runtime" Display="expand" InstallDefault="local" Level="3"
               Title="All">
	<MergeRef Id="MSVCRTMEM"/>
	<MergeRef Id="MSVCRTPOL"/>
	<MergeRef Id="MSVCRTMFC"/>
	<MergeRef Id="MSVCRTPFC"/>
	<MergeRef Id="MSVCRTMFL"/>
	<MergeRef Id="MSVCRTPFL"/>
      </Feature>  

      <Media Id="1" Cabinet="disk1.cab" CompressionLevel="high" EmbedCab="yes" />

      <Property Id="INSTALLLEVEL" Value="3" />

    </Product>
</Wix>
