t (C) Microsoft Corporation. All rights reserved.
***********************************************************************************************
-->

<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <PropertyGroup>
    <_PlatformFolder Condition="'$(_PlatformFolder)' == ''">$(VCTargetsPath)\Platforms\$(Platform)\</_PlatformFolder>
    <_ToolsetTargetsPath>$(_PlatformFolder)PlatformToolsets\$(PlatformToolset)\Toolset.targets</_ToolsetTargetsPath>
    <ToolsetTargetsFound Condition="Exists('$(_ToolsetPropsPath)')">true</ToolsetTargetsFound>
    <VCTargetsPathEffective Condition="'$(ToolsetTargetsFound)' == 'true'">$(VCTargetsPath)</VCTargetsPathEffective>
    
    <!-- VCMessages could only print messages from the active task dll.  Since the new message is only present in the current task dll,
    setting MinSupportedVCTargetsVersion prevents the redirection which will keep the task to current. -->
    <_Error64bitToolsNotInstalled Condition="'$(_Error64bitToolsNotInstalled)' == '' and '$(_CheckDev11ToolsInstalled)' == 'true' and '$(DefaultToolArchitecture)' == 'Native64bit' 
      and (('$(PlatformToolset)' == 'v110' and '$(_IgnoreInstalledPlatformToolset_v110)' != 'true') or ('$(PlatformToolset)' == 'v110_xp' and '$(_IgnoreInstalledPlatformToolset_v110_xp)' != 'true'))">true</_Error64bitToolsNotInstalled>
    <MinSupportedVCTargetsVersion Condition="'$(_Error64bitToolsNotInstalled)' == 'true'">v120</MinSupportedVCTargetsVersion>
  </PropertyGroup>

  <!-- Import Before -->
  <Import Condition="Exists('$(_PlatformFolder)ImportBefore')" Project="$(_PlatformFolder)ImportBefore\*.targets"/>
  <!-- Import platform toolset file if found in this version -->
  <Import Condition="'$(ToolsetTargetsFound)' == 'true'" Project="$(_ToolsetTargetsPath)" />
  <!-- Try to find the toolset in older versions if MinSupportedVCTargetsVersion allows. -->
  <Import Condition="'$(ToolsetTargetsFound)' != 'true' and '$(MinSupportedVCTargetsVersion)' != 'v120'" Project="Microsoft.Cpp.Platform.Redirect.targets" />
  <!-- If ToolsetTargetsFound still not found, then fallback to current Toolset so the project can still load. -->
  <Import Condition="'$(ToolsetTargetsFound)' != 'true'" Project="$(_PlatformFolder)PlatformToolsets\$(DefaultPlatformToolset)\Toolset.targets" />

  <PropertyGroup>
    <PrepareForBuildDependsOn>PlatformPrepareForBuild;$(PrepareForBuildDependsOn)</PrepareForBuildDependsOn>
  </PropertyGroup>
  
  <Target Name="PlatformPrepareForBuild" DependsOnTargets="$(PlatformPrepareForBuildDependsOn)" Condition="'$(DesignTimeBuild)'!='true'">
    <PropertyGroup>
      <ConfigurationPlatformExists Condition="'%(ProjectConfiguration.Identity)' == '$(Configuration)|$(Platform)'">true</ConfigurationPlatformExists>
      <_CurrentPlatformToolsetShortName Condition="'$(PlatformToolset)' == 'v110'">$(_PlatformToolsetShortNameFor_v110)</_CurrentPlatformToolsetShortName>
      <_CurrentPlatformToolsetShortName Condition="'$(PlatformToolset)' == 'v110_xp'">$(_PlatformToolsetShortNameFor_v110_xp)</_CurrentPlatformToolsetShortName>
      <_CurrentPlatformToolsetShortName Condition="'$(PlatformToolset)' == 'v100'">$(_PlatformToolsetShortNameFor_v100)</_CurrentPlatformToolsetShortName>
      <_CurrentPlatformToolsetShortName Condition="'$(PlatformToolset)' == 'v90'">$(_PlatformToolsetShortNameFor_v90)</_CurrentPlatformToolsetShortName>
      <_CurrentPlatformToolsetShortName Condition="'$(_CurrentPlatformToolsetShortName)' == ''">$(PlatformToolset)</_CurrentPlatformToolsetShortName>
    </PropertyGroup>

    <!--
    Error out if the toolset is from Express and the environment is 64bit tools and down targetting. 
    MSB8032: The Platform or PlatformToolset is not available from a 64bit environment.  Consider building from 32bit environment instead.
    -->
    <VCMessage Code="MSB8032" Type="Error" Condition="'$(_Error64bitToolsNotInstalled)' == 'true'" />

     <!-- Error out when building an platform that is not set in the project file -->
    <VCMessage Code="MSB8013" Type="Error" Arguments="$(Configuration)|$(Platform)" Condition="'$(ConfigurationPlatformExists)' != 'true'" />

    <!-- Error out if toolset does not exists in Visual Studio 2010 or 2012 -->
    <VCMessage Code="MSB8020" Type="Error" Arguments="$(_CurrentPlatformToolsetShortName);$(PlatformToolset)" Condition="'$(ToolsetTargetsFound)' != 'true'" />

  </Target>

  <!-- Import After -->
  <Import Condition="'$(ToolsetTargetsFound)' == 'true' and Exists('$(_PlatformFolder)ImportAfter')" Project="$(_PlatformFolder)ImportAfter\*.targets"/>
</Project>
