<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup>
    <Natvis Include="$(SolutionDir)tools\ConsoleTypes.natvis" />
  </ItemGroup>

  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />

  <ItemDefinitionGroup>
    <!-- Definition the program database type has to come after Microsoft.Cpp.props or it will be
         rewritten to /ZI (edit-and-continue) type every time. -->
    <ClCompile>
      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
    </ClCompile>
    <Link>
      <AdditionalDependencies>onecoreuap_apiset.lib;d3dcompiler.lib;dwmapi.lib;uxtheme.lib;shlwapi.lib;ntdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
    </Link>
  </ItemDefinitionGroup>

  <!-- DLLs Only -->
  <ItemDefinitionGroup Condition="'$(ConfigurationType)' == 'DynamicLibrary'">
    <ClCompile>
      <PreprocessorDefinitions>_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
  </ItemDefinitionGroup>

  <!-- Static Libs Only -->
  <ItemDefinitionGroup Condition="'$(ConfigurationType)' == 'StaticLibrary'">
    <ClCompile>
      <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
  </ItemDefinitionGroup>

  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

  <!-- PGO -->
  <Import Condition="'$(PgoTarget)' == 'true' And '$(PGOBuildMode)' == 'Optimize'" Project="$(SolutionDir)packages\$(PGODatabaseId).$(PGODatabaseVersion)\build\PGO.targets" />
  <Import Condition="'$(PgoTarget)' == 'true' And '$(PGOBuildMode)' == 'Instrument'" Project="$(SolutionDir)\src\common.pgo.runtime.props" />

  <!-- Exclude our dependencies from static analysis. CAExcludePath can only be
       set after we've imported Microsoft.Cpp.targets -->
  <PropertyGroup>
    <CAExcludePath>$(SolutionDir)\dep\;$(CAExcludePath)</CAExcludePath>
  </PropertyGroup>

  <Target Name="_ComputePrecompToCleanUp">
    <ItemGroup>
      <PCHFileToClean Include="$(IntDir)\**\*.pch" />
      <PCHFileToClean Include="$(IntDir)\**\precomp.obj" />
      <_PCHFileToCleanWithTimestamp Include="@(PCHFileToClean)" Condition="'%(Identity)' != ''">
        <LastWriteTime>$([System.IO.File]::GetLastWriteTime('%(Identity)'))</LastWriteTime>
      </_PCHFileToCleanWithTimestamp>
    </ItemGroup>
  </Target>
  <!-- Instead of outright deleting the PCHs, we want to trick the "project freshness detector" by
       emitting empty files that look suspiciously like the PCHs it's expecting.
       It's of utmost importance that their timestamps match up. -->
  <Target Name="CleanUpPrecompForSmallCIAgents"
          DependsOnTargets="_ComputePrecompToCleanUp"
          AfterTargets="AfterBuild"
          Condition="'$(OpenConsoleCleanPCH)' == 'true' and '$(AGENT_ID)' != '' and !$(ProjectName.Contains('TerminalApp'))">
    <!-- We just need to keep *TerminalApp*'s PCHs because they get rebuilt more often. -->
    <Delete Files="@(_PCHFileToCleanWithTimestamp)"/>
    <Touch Files="@(_PCHFileToCleanWithTimestamp)" Time="%(LastWriteTime)" AlwaysCreate="true" />
    <Message Text="PCH and Precomp object @(_PCHFileToCleanWithTimestamp) has been deleted for $(ProjectName)." />
  </Target>
</Project>
