<!--
***********************************************************************************************
Microsoft.Cpp.DesignTime.targets

WARNING:  DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
          created a backup copy.  Incorrect changes to this file will make it
          impossible to load or build your projects from the command-line or the IDE.

This file contains targets that are only used by IDE and not the real build

Copyright (C) Microsoft Corporation. All rights reserved.
***********************************************************************************************
-->

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" TreatAsLocalProperty="OutDir">
  <!-- Fix up for old Smart Devices projects-->
  <PropertyGroup Condition="'$(_UIModelDllPath)' == '' and '$(SmartDeviceProject)' != ''">
    <_UIModelDllPath>$(VCIDEInstallDir)\VCPackages\CE.dll</_UIModelDllPath>
  </PropertyGroup>

  <PropertyGroup Condition ="'$(DesignTimeBuild)' == 'true'">
    <!-- This will make GetTargetPathWithTargetPlatformMoniker during ResolveProjectReferences -->
    <IntelliSenseBuild>true</IntelliSenseBuild>
    <!-- Disable warning targets, they are not useful in designtime build -->
    <IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
    <_FindDependencies>false</_FindDependencies>
    <BuildingProject>false</BuildingProject>
  </PropertyGroup>

  <PropertyGroup>
    <!-- We want to make sure we run these targets identically for all designtime build to ensure consistent results when they are bundled -->
    <DesignTimeBuildInitTargets>$(DetermineProjectTypeTargets);InitGetClCommandLines;ResolveReferences;FixupReferences</DesignTimeBuildInitTargets>
  </PropertyGroup>

  <PropertyGroup>
    <AddManagedCapability Condition="'$(AddManagedCapability)' == '' and '$(ManagedAssembly)' == 'true'">true</AddManagedCapability>
  </PropertyGroup>

  <!-- Capabilities for all vc projects. -->
  <ItemGroup>
    <ProjectCapability Include="AssemblyReferences;COMReferences;ProjectReferences;WinRTReferences;SDKReferences;SharedProjectReferences" Condition="'$(IncludeVCDefaultReferenceCapabilities)' != 'false'"/>
    <ProjectCapability Include="OutputGroups;AllTargetOutputGroups;VisualStudioWellKnownOutputGroups" Condition="'$(IncludeVCDefaultOutputGroupsCapabilities)' != 'false'"/>
    <ProjectCapability Include="ProjectConfigurationsDeclaredAsItems" />
    <ProjectCapability Include="PropertyManager" Condition="'$(PropertyManagerSupported)' != 'false'"/>
    <ProjectCapability Include="managed" Condition="'$(AddManagedCapability)' == 'true'"/>
    <ProjectCapability Include="native" Condition="'$(AddManagedCapability)' != 'true'"/>
    <!-- enables local windows debugger check if the exe is a console application -->
    <ProjectCapability Include="IntegratedConsoleDebugging" />
    <ProjectCapability Include="SupportsOnlineEnvironments" Condition="'$(ApplicationType)' == ''" />
  </ItemGroup>

  <!-- Additional metadata needed in resolved project references -->
  <ItemDefinitionGroup>
    <TargetPathWithTargetPlatformMoniker>
      <ProjectGuid Condition ="'%(TargetPathWithTargetPlatformMoniker.ProjectGuid)' == ''">$(ProjectGuid)</ProjectGuid>
      <ReferenceSourceTarget Condition ="'%(TargetPathWithTargetPlatformMoniker.ReferenceSourceTarget)' == ''">ProjectReference</ReferenceSourceTarget>
      <MsbuildSourceProjectFile Condition ="'%(TargetPathWithTargetPlatformMoniker.MsbuildSourceProjectFile)' == ''">$(MSBuildProjectFullPath)</MsbuildSourceProjectFile>
    </TargetPathWithTargetPlatformMoniker>
  </ItemDefinitionGroup>

  <Target Name="InitGetClCommandLines">
    <!-- Add a fake cpp file to get Configuration options. It needs to be done before other targets running to ensure correct results -->
    <ItemGroup>
      <ClCompile Include="__temporary.cpp">
        <ConfigurationOptions>true</ConfigurationOptions>
      </ClCompile>
    </ItemGroup>

    <PropertyGroup>
      <!-- Disable ref resolution if we know we won't get anything useful from it. Set AlwaysResolveReferencesDesignTime to true to override this behavior -->
      <ResolveReferencesDependsOn Condition="'$(WinMDAssembly)' != 'true' and '$(ManagedAssembly)' != 'true' and '$(AlwaysResolveReferencesDesignTime)' != 'true'"></ResolveReferencesDependsOn>
      <ReferenceResolutionDisabled Condition="'$(ResolveReferencesDependsOn)' == ''">true</ReferenceResolutionDisabled>
    </PropertyGroup>
  </Target>


  <Target Name="FixupReferences">
    <ItemGroup>
      <ReferencePath>
        <!-- when winmd file does not exist yet <WinMdFile> metadata is not set by RAR. Add it here so it is still included in IntelliSense command line -->
        <WinMDFile Condition="'%(ReferencePath.WinMDFile)' == '' and '%(ReferencePath.Extension)' == '.winmd'">true</WinMDFile>
      </ReferencePath>
    </ItemGroup>
  </Target>

  <UsingTask TaskName="CLCommandLine" AssemblyFile="$(CurrentVCTargetsPath)\Microsoft.Build.CPPTasks.Common.dll"/>
  <Target Name="GetClCommandLines"
          Returns="@(ClCommandLines)"
          DependsOnTargets="$(DesignTimeBuildInitTargets);$(ComputeCompileInputsTargets)" >

    <ItemGroup>
      <ClCompile>
        <!-- figure out obj file directory which IntelliSense needs for #import support, but we don't want to use '%(ClCompile.ObjectFileName)' as it breaks MsBuild batching -->
        <ObjectFileDirectory Condition="'%(ClCompile.ObjectFileName)' != ''">$([System.IO.Path]::GetDirectoryName('%(ClCompile.ObjectFileName))'))\</ObjectFileDirectory>
        <ModuleOutputDirectory Condition="'%(ClCompile.ModuleOutputFile)' != ''">$([System.IO.Path]::GetDirectoryName('%(ClCompile.ModuleOutputFile))'))\</ModuleOutputDirectory>

        <!-- Option to include files that are excluded from build for IntelliSense. -->
        <ExcludedFromBuild Condition="'$(IgnoreExcludedFromBuild)' == 'true'" />
      </ClCompile>
    </ItemGroup>

    <CLCommandLine
            Condition                          ="'%(ClCompile.ExcludedFromBuild)' != 'true'"
            BuildingInIDE                      ="true"
            Sources                            ="@(ClCompile)"

            ClangMode                          ="%(ClCompile.ClangMode)"
            ClangClMode                        ="%(ClCompile.ClangClMode)"

            AdditionalHeaderUnitDependencies   ="%(ClCompile.AdditionalHeaderUnitDependencies)"
            AdditionalIncludeDirectories       ="%(ClCompile.AdditionalIncludeDirectories)"
            AdditionalModuleDependencies       ="%(ClCompile.AdditionalModuleDependencies)"
            AdditionalBMIDirectories           ="%(ClCompile.AdditionalBMIDirectories)"
            AdditionalOptions                  ="%(ClCompile.AdditionalOptions)"
            AdditionalUsingDirectories         ="%(ClCompile.AdditionalUsingDirectories)"
            CallingConvention                  ="%(ClCompile.CallingConvention)"
            CompileAsManaged                   ="%(ClCompile.CompileAsManaged)"
            CompileAsWinRT                     ="%(ClCompile.CompileAsWinRT)"
            CompileAs                          ="%(ClCompile.CompileAs)"
            ConformanceMode                    ="%(ClCompile.ConformanceMode)"
            DisableLanguageExtensions          ="%(ClCompile.DisableLanguageExtensions)"
            DisableSpecificWarnings            ="%(ClCompile.DisableSpecificWarnings)"
            EnableEnhancedInstructionSet       ="%(ClCompile.EnableEnhancedInstructionSet)"
            EnableVectorLength                 ="%(ClCompile.EnableVectorLength)"
            EnableModules                      ="%(ClCompile.EnableModules)"
            ErrorReporting                     ="%(ClCompile.ErrorReporting)"
            ExceptionHandling                  ="%(ClCompile.ExceptionHandling)"
            ExcludedInputPaths                 ="$(ExcludePath)"
            ExpandAttributedSource             ="%(ClCompile.ExpandAttributedSource)"
            ExternalTemplatesDiagnostics       ="%(ClCompile.ExternalTemplatesDiagnostics)"
            ExternalWarningLevel               ="%(ClCompile.ExternalWarningLevel)"
            FloatingPointExceptions            ="%(ClCompile.FloatingPointExceptions)"
            FloatingPointModel                 ="%(ClCompile.FloatingPointModel)"
            ForceConformanceInForLoopScope     ="%(ClCompile.ForceConformanceInForLoopScope)"
            ForcedIncludeFiles                 ="%(ClCompile.ForcedIncludeFiles)"
            ForcedUsingFiles                   ="%(ClCompile.ForcedUsingFiles)"
            IgnoreStandardIncludePath          ="%(ClCompile.IgnoreStandardIncludePath)"
            InlineFunctionExpansion            ="%(ClCompile.InlineFunctionExpansion)"
            IntrinsicFunctions                 ="%(ClCompile.IntrinsicFunctions)"
            LanguageStandard                   ="%(ClCompile.LanguageStandard)"
            LanguageStandard_C                 ="%(ClCompile.LanguageStandard_C)"
            ModuleOutputFile                   ="%(ClCompile.ModuleOutputDirectory)" 
            OpenMPSupport                      ="%(ClCompile.OpenMPSupport)"
            ObjectFileName                     ="%(ClCompile.ObjectFileDirectory)"
            PrecompiledHeader                  ="%(ClCompile.PrecompiledHeader)"
            PrecompiledHeaderFile              ="%(ClCompile.PrecompiledHeaderFile)"
            PrecompiledHeaderOutputFile        ="%(ClCompile.PrecompiledHeaderOutputFile)"
            PreprocessKeepComments             ="%(ClCompile.PreprocessKeepComments)"
            PreprocessorDefinitions            ="%(ClCompile.PreprocessorDefinitions)"
            PreprocessSuppressLineNumbers      ="%(ClCompile.PreprocessSuppressLineNumbers)"
            PreprocessToFile                   ="%(ClCompile.PreprocessToFile)"
            RuntimeLibrary                     ="%(ClCompile.RuntimeLibrary)"
            RuntimeTypeInfo                    ="%(ClCompile.RuntimeTypeInfo)"
            SmallerTypeCheck                   ="%(ClCompile.SmallerTypeCheck)"
            StdIfcDirectory                    ="%(ClCompile.StdIfcDirectory)"
            StructMemberAlignment              ="%(ClCompile.StructMemberAlignment)"
            TranslateIncludes                  ="%(ClCompile.TranslateIncludes)"
            TreatAngleIncludeAsExternal        ="%(ClCompile.TreatAngleIncludeAsExternal)"
            TreatSpecificWarningsAsErrors      ="%(ClCompile.TreatSpecificWarningsAsErrors)"
            TreatWarningAsError                ="%(ClCompile.TreatWarningAsError)"
            TreatWChar_tAsBuiltInType          ="%(ClCompile.TreatWChar_tAsBuiltInType)"
            UndefineAllPreprocessorDefinitions ="%(ClCompile.UndefineAllPreprocessorDefinitions)"
            UndefinePreprocessorDefinitions    ="%(ClCompile.UndefinePreprocessorDefinitions)"
            UseStandardPreprocessor            ="%(ClCompile.UseStandardPreprocessor)"
            WarningLevel                       ="%(ClCompile.WarningLevel)"
            WinRTNoStdLib                      ="%(ClCompile.WinRTNoStdLib)"

            CLanguageStandard                  ="%(ClCompile.CLanguageStandard)"
            CppLanguageStandard                ="%(ClCompile.CppLanguageStandard)"
            UseShortEnums                      ="%(ClCompile.UseShortEnums)"
            MSExtensions                       ="%(ClCompile.MSExtensions)"
            MSCompatibility                    ="%(ClCompile.MSCompatibility)"
            MSCVersion                         ="%(ClCompile.MSCVersion)"
            ScanSourceForModuleDependencies    ="%(ClCompile.ScanSourceForModuleDependencies)"
            LibraryModuleName                  ="%(ClCompile.LibraryModuleName)"

            TrackerLogDirectory                ="%(ClCompile.TrackerLogDirectory)"

            TLogReadFiles                      ="@(CLTLogReadFiles)"
            TLogWriteFiles                     ="@(CLTLogWriteFiles)"
            ToolExe                            ="$(CLToolExe)"
            ToolPath                           ="$(CLToolPath)"
            ToolArchitecture                   ="$(CLToolArchitecture)"
            TrackerFrameworkPath               ="$(CLTrackerFrameworkPath)"
            TrackerSdkPath                     ="$(CLTrackerSdkPath)"
    >
      <Output TaskParameter="CommandLines" ItemName="ClCommandLines"/>
    </CLCommandLine>

    <CLCommandLine Condition="'@(FxCompile)' != ''"
            BuildingInIDE                      ="true"
            Sources                            ="@(FxCompile)"

            AdditionalIncludeDirectories       ="%(FxCompile.AdditionalIncludeDirectories)"
            PreprocessorDefinitions            ="%(FxCompile.PreprocessorDefinitions)"
    >
      <Output TaskParameter="CommandLines" ItemName="ClCommandLines"/>
    </CLCommandLine>

    <ItemGroup>
      <ClCommandLines>
        <ContainsReferencedProjectsData Condition="'$(ResolveReferencesDependsOn)' != ''">true</ContainsReferencedProjectsData>
      </ClCommandLines>
    </ItemGroup>
  </Target>

  <PropertyGroup>
    <GetClCommandLineForReferenceSupported>true</GetClCommandLineForReferenceSupported>
  </PropertyGroup>

  <!-- This target returns additional cl command line which projects that reference this project can use instead of using msbuild's resolve references  -->
  <Target Name="GetClCommandLineForReference"
        Returns="@(ClCommandLineForReference)"
        DependsOnTargets="$(DesignTimeBuildInitTargets);$(GetClCommandLineForReferenceDependsOn)" >

    <PropertyGroup Condition="'@(PublicIncludeDirectories)' != ''">
      <CreateCommandLineForReference>true</CreateCommandLineForReference>
    </PropertyGroup>
    <ItemGroup Condition="'@(PublicIncludeDirectories)' != ''">
      <ProjectDataForReference Include="__temp__.cpp">
        <AdditionalIncludeDirectories>%(ProjectDataForReference.AdditionalIncludeDirectories);@(PublicIncludeDirectories->Metadata('FullPath'))</AdditionalIncludeDirectories>
        <!--<ForcedUsingFiles Condition ="'$(WinMDAssembly)' == 'true'">@(GetResolvedWinMD)</ForcedUsingFiles>
          <ForcedUsingFiles Condition ="'$(ManagedAssembly)' == 'true'">$(TargetPath)</ForcedUsingFiles>-->
      </ProjectDataForReference>
    </ItemGroup>

    <CLCommandLine
            Condition="'$(CreateCommandLineForReference)' == 'true'"
            BuildingInIDE                      ="true"
            Sources                            ="@(ProjectDataForReference)"

            ClangMode                          ="false"
            EmitCompileOnlySwitch              ="false"

            AdditionalIncludeDirectories       ="%(ProjectDataForReference.AdditionalIncludeDirectories)"
    >
      <Output TaskParameter="CommandLines" ItemName="ClCommandLineForReference"/>
    </CLCommandLine>
  </Target>

  <Target Name="GetProjectDirectories"
          Returns="@(_ProjectDirectories)"
          DependsOnTargets="$(DetermineProjectTypeTargets)">

    <PropertyGroup Condition="'$(UseEnv)' == 'true'">
      <IncludePath>$(INCLUDE)</IncludePath>
      <LibraryPath>$(LIB)</LibraryPath>
      <ReferencePath>$(LIBPATH)</ReferencePath>
    </PropertyGroup>

    <PropertyGroup Condition="'$(ConfigurationType)' == 'Makefile'">
      <IncludePath>$(NMakeIncludeSearchPath);$(IncludePath)</IncludePath>
      <ReferencePath>$(NMakeAssemblySearchPath);$(ReferencePath)</ReferencePath>
    </PropertyGroup>
 
    <ItemGroup>
      <_ProjectDirectories Include="dummy">
        <IncludePath>$(IncludePath)</IncludePath>
        <ExternalIncludePath>$(ExternalIncludePath)</ExternalIncludePath>
        <FrameworkIncludePath>$(FrameworkIncludePath)</FrameworkIncludePath>
        <ExcludePath>$(ExcludePath)</ExcludePath>
        <ReferencePath>$(ReferencePath);$(LibraryPath)</ReferencePath>
        <ProjectDir>$(ProjectDir)</ProjectDir>
        <ToolsetISenseIdentifier>$(ToolsetISenseIdentifier)</ToolsetISenseIdentifier>
      </_ProjectDirectories>
    </ItemGroup>
  </Target>

  <Target Name="GetGeneratedFiles"
          Returns="@(_GeneratedFiles)"
          DependsOnTargets="$(DesignTimeBuildInitTargets);$(GeneratedFilesOutputGroupDependsOn)" >

    <ItemGroup>
      <_GeneratedFiles Include="%(GeneratedFilesOutputGroup.FullPath)" />
    </ItemGroup>

  </Target>

  <Target Name="GetProjectReferencesInfo"
          Returns="@(_ProjectReferencesInfo)"
          DependsOnTargets="$(DesignTimeBuildInitTargets)">

    <ItemGroup>
      <_ProjectReferencesInfo Include="@(ReferencePath->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))"
                              Condition="'%(ReferencePath.ReferenceOutputAssembly)' != 'false'" />
    </ItemGroup>

    <Message Condition="'$(_REFERENCE_DEBUG)' ==  'true'"
             Text="ProjectReferenceResolvedPath=%(_ProjectReferencesInfo.Identity)&#xA;
                   ProjectGuid=%(_ProjectReferencesInfo.Project)&#xA;
                   ProjectFile=%(_ProjectReferencesInfo.MsbuildSourceProjectFile)&#xA;"
             Importance="High" />
    <Message Condition="'$(_REFERENCE_DEBUG)' ==  'true'"
             Text="ReferencePath=%(ReferencePath.Identity)&#xA;
                   ReferenceSourceTarget=%(ReferencePath.ReferenceSourceTarget)&#xA;
                   ReferenceOutputAssembly=%(ReferencePath.ReferenceOutputAssembly)&#xA;"
             Importance="High" />
  </Target>

  <Target Name="GetAssemblyReferences"
        Returns="@(_AssemblyReferences)"
        DependsOnTargets="$(DesignTimeBuildInitTargets)">
    <ItemGroup Condition ="'$(ManagedAssembly)' == 'true'">
      <_AssemblyReferences Include="@(Reference)" Condition="'%(Reference.IsWinMDFile)' != 'true' and '%(Reference.FrameworkReferenceName)' == ''">
        <!-- this will be overriden with Full path if reference is resolved-->
        <VCReferenceIdentifier Condition="'%(Reference.HintPath)' != ''">%(Reference.HintPath)</VCReferenceIdentifier>
        <VCReferenceIdentifier Condition="'%(Reference.HintPath)' == ''">%(Reference.Identity)</VCReferenceIdentifier>
        <Kind>VCAssemblyReference</Kind>
      </_AssemblyReferences>
    </ItemGroup>
  </Target>

  <Target Name="GetWinMDReferences"
        Returns="@(_WinMDReferences)"
        DependsOnTargets="$(DesignTimeBuildInitTargets)">
    <ItemGroup Condition ="'$(WinMDAssembly)' == 'true'">
      <_WinMDReferences Include="@(Reference)" Condition="'%(Reference.IsWinMDFile)' == 'true'">
        <!-- this will be overriden with Full path if reference is resolved-->
        <VCReferenceIdentifier Condition="'%(Reference.HintPath)' != ''">%(Reference.HintPath)</VCReferenceIdentifier>
        <VCReferenceIdentifier Condition="'%(Reference.HintPath)' == ''">%(Reference.Identity)</VCReferenceIdentifier>
        <Kind>VCWinRTReference</Kind>
      </_WinMDReferences>
    </ItemGroup>
  </Target>

  <Target Name="GetComReferences"
        Returns="@(ComReference)"
        DependsOnTargets="$(DesignTimeBuildInitTargets)">
    <ItemGroup Condition ="'$(ManagedAssembly)' == 'true'">
      <ComReference>
        <VCReferenceIdentifier>{%(ComReference.Guid)}\%(ComReference.VersionMajor).%(ComReference.VersionMinor)</VCReferenceIdentifier>
        <ControlGUID>{%(ComReference.Guid)}</ControlGUID>
        <ControlLocale>%(ComReference.Lcid)</ControlLocale>
        <ControlVersion>%(ComReference.VersionMajor).%(ComReference.VersionMinor)</ControlVersion>
        <TypeLibraryName>%(ComReference.FileName)</TypeLibraryName>
        <Kind>VCActiveXReference</Kind>
      </ComReference>
    </ItemGroup>
  </Target>

  <Target Name="GetSDKReferences"
        Returns="@(SdkReference)"
        DependsOnTargets="$(DesignTimeBuildInitTargets)">
    <ItemGroup Condition ="'$(WinMDAssembly)' == 'true'">
      <SdkReference>
        <VCReferenceIdentifier>%(SdkReference.Identity)</VCReferenceIdentifier>
        <Kind>VCSdkReference</Kind>
      </SdkReference>
    </ItemGroup>
  </Target>


  <Target Name="GetProjectReferences"
        Returns="@(ProjectReference)"
        DependsOnTargets="$(DesignTimeBuildInitTargets)">
    <ItemGroup>
      <ProjectReference>
        <Name Condition="'%(ProjectReference.Name)' == ''">%(ProjectReference._ReferencedProjectName)</Name>
        <VCReferenceIdentifier>%(ProjectReference.Project)</VCReferenceIdentifier>
        <!-- ItemIdentifier is used to match resolved reference's 'OriginalItemSpec' metadata -->
        <ItemIdentifier>%(ProjectReference.Project)</ItemIdentifier>
        <Kind>VCProjectReference</Kind>
        <ProjectFile>%(ProjectReference.FullPath)</ProjectFile>
      </ProjectReference>
      <ProjectReference>
        <Name Condition="'%(ProjectReference.Name)' == ''">%(ProjectReference.FileName)</Name>
      </ProjectReference>
    </ItemGroup>
  </Target>

  <Target Name="GetForeignReferences"
        Returns="@(_ForeignReferences)"
        DependsOnTargets="$(DesignTimeBuildInitTargets);$(GetForeignReferencesDependsOn)"
   />

  <Target Name="GetResolvedReferences"
          Returns="@(ReferencePath)"
          DependsOnTargets="$(DesignTimeBuildInitTargets);$(GetAllReferencesInfoDependsOn)">
    <ItemGroup>
      <!-- Fix/assign VCReferenceIdentifier to implcit references added by targets -->
      <ReferencePath Condition="'%(ReferencePath.ReferenceSourceTarget)' == 'ResolveAssemblyReference'">
        <VCReferenceIdentifier Condition="'%(ReferencePath.FullPath)' != ''">%(ReferencePath.FullPath)</VCReferenceIdentifier>
        <Kind Condition="'%(ReferencePath.Implicit)' == 'true' and '%(ReferencePath.IsWinMD)' != true">VCImplicitAssemblyReference</Kind>
        <Kind Condition="'%(ReferencePath.Implicit)' == 'true' and '%(ReferencePath.IsWinMD)' == true">VCImplicitWinRTReference</Kind>
      </ReferencePath>
      <ReferencePath Condition="'%(ReferencePath.ReferenceSourceTarget)' == 'ResolveComReference'">
        <VCReferenceIdentifier>{%(ReferencePath.Guid)}\%(ReferencePath.VersionMajor).%(ReferencePath.VersionMinor)</VCReferenceIdentifier>
        <Kind Condition="'%(ReferencePath.Implicit)' == 'true'">VCImplicitActivXReference</Kind>
        <ControlFullPath>%(ReferencePath.FullPath)</ControlFullPath>
      </ReferencePath>
      <ReferencePath Condition="'%(ReferencePath.ReferenceSourceTarget)' == 'ResolveSdkReference'">
        <VCReferenceIdentifier>%(ReferencePath.OriginalItemSpec)</VCReferenceIdentifier>
        <Kind Condition="'%(ReferencePath.Implicit)' == 'true'">VCImplicitSdkReference</Kind>
      </ReferencePath>
      <ReferencePath Condition="'%(ReferencePath.ReferenceSourceTarget)' == 'ResolveProjectReference'">
        <VCReferenceIdentifier>%(ReferencePath.Project)</VCReferenceIdentifier>
      </ReferencePath>
    </ItemGroup>
    <Message Condition="'$(_REFERENCE_DEBUG)' ==  'true'"
             Text="ReferencePath=%(ReferencePath.Identity)&#xA;
                   ReferenceSourceTarget=%(ReferencePath.ReferenceSourceTarget)&#xA;
                   ReferenceOutputAssembly=%(ReferencePath.ReferenceOutputAssembly)&#xA;"
             Importance="High" />
  </Target>

  
  <Target
      Name="GetTargetPathWithTargetPlatformMoniker"
      BeforeTargets="GetTargetPath"
      DependsOnTargets="$(GetTargetPathWithTargetPlatformMonikerDependsOn);"
      Returns="@(TargetPathWithTargetPlatformMoniker)">

    <!-- If GetTargetPath from older versions (or overriden GetTargetPath) did not populate the group, we'll do it here -->
    <ItemGroup Condition="'@(TargetPathWithTargetPlatformMoniker)' == ''">
      <TargetPathWithTargetPlatformMoniker Include="@(WinMDFullPath)" />
      <TargetPathWithTargetPlatformMoniker Include="$(TargetPath)" Condition="'@(TargetPathWithTargetPlatformMoniker)' == ''">
        <ResolveableAssembly Condition="'$(ConfigurationType)' != 'StaticLibrary'">$(ManagedAssembly)</ResolveableAssembly>
        <ResolveableAssembly Condition="'$(ConfigurationType)' == 'StaticLibrary'">false</ResolveableAssembly>
      </TargetPathWithTargetPlatformMoniker>
    </ItemGroup>

    <ItemGroup>
      <TargetPathWithTargetPlatformMoniker>
        <TargetPlatformMoniker Condition ="'%(TargetPathWithTargetPlatformMoniker.TargetPlatformMoniker)' == ''">$(TargetPlatformMoniker)</TargetPlatformMoniker>
        <TargetPlatformIdentifier Condition ="'%(TargetPathWithTargetPlatformMoniker.TargetPlatformIdentifier)' == ''">$(TargetPlatformIdentifier)</TargetPlatformIdentifier>
      </TargetPathWithTargetPlatformMoniker>
    </ItemGroup>

    <Message Condition="'$(_REFERENCE_DEBUG)' ==  'true'" Text="****** GetTargetPathWithTargetPlatformMoniker:TargetPathWithTargetPlatformMoniker=%(TargetPathWithTargetPlatformMoniker.Identity)&#xA;
                                                                ****** ProjectGuid=%(TargetPathWithTargetPlatformMoniker.ProjectGuid)&#xA;
                                                                ****** ProjectFile=%(TargetPathWithTargetPlatformMoniker.MsbuildSourceProjectFile)&#xA;
                                                                ****** TargetPlatformMoniker=%(TargetPathWithTargetPlatformMoniker.TargetPlatformMoniker)&#xA;
                                                                ****** TargetPlatformIdentifier=%(TargetPathWithTargetPlatformMoniker.TargetPlatformIdentifier)&#xA;
                                                                " Importance="High" />
  </Target>


  <Target Name="_PrintPropertyPages">
    <ItemGroup>
      <PropertyPageSchema>
        <ExistsOnDisk Condition="Exists(%(PropertyPageSchema.Identity))">true</ExistsOnDisk>
      </PropertyPageSchema>
    </ItemGroup>
    <Message Text="PropertyPageSchema='%(PropertyPageSchema.Identity)'&#xA;ExistsOnDisk='%(PropertyPageSchema.ExistsOnDisk)'&#xA;Context='%(PropertyPageSchema.Context)'&#xA;" Importance="High" />
    <Message Text="ProjectTools=@(ProjectTools)&#xA;" Importance="High" />
  </Target>

  <Target Name="_PrintIntellisenseInfo"
        DependsOnTargets="GetProjectDirectories;GetClCommandLines;GetClCommandLineForReference;GetGeneratedFiles;GetProjectReferencesInfo">
    <Message Text="****** Configuration Settings:" Importance="High" />
    <Message Condition="'%(ClCommandLines.ConfigurationOptions)' == 'true'" Text="****** Files=%(ClCommandLines.Files)&#xA;****** CommandLine=%(ClCommandLines.Identity)&#xA;" Importance="High" />
    <Message Condition="'%(ClCommandLines.ConfigurationOptions)' != 'true'" Text="****** Files=%(ClCommandLines.Files)&#xA;****** CommandLine=%(ClCommandLines.Identity)&#xA;" Importance="High" />
    <Message Text="****** ExecutablePath=$(ExecutablePath)&#xA;" Importance="High" />
    <Message Text="****** GeneratedFiles=@(_GeneratedFiles)&#xA;" Importance="High" />
    <Message Text="****** IncludePath=%(_ProjectDirectories.IncludePath)&#xA;" Importance="High" />
    <Message Text="****** FrameworkIncludePath=%(_ProjectDirectories.FrameworkIncludePath)&#xA;" Importance="High" />
    <Message Text="****** ExcludePath=%(_ProjectDirectories.ExcludePath)&#xA;" Importance="High" />
    <Message Text="****** ReferencePath=%(_ProjectDirectories.ReferencePath)&#xA;" Importance="High" />
    <Message Text="****** LibraryPath=$(LibraryPath)&#xA;" Importance="High" />
    <Message Text="****** ToolsetISenseIdentifier=%(_ProjectDirectories.ToolsetISenseIdentifier)&#xA;" Importance="High" />

    <Message Condition="'@(_ProjectReferencesInfo)' != ''"
             Text="ProjectReferenceResolvedPath=%(_ProjectReferencesInfo.Identity)&#xA;
                   ReferencedProjectGuid=%(_ProjectReferencesInfo.Project)&#xA;
                   ReferencedProjectFile=%(_ProjectReferencesInfo.MsbuildSourceProjectFile)&#xA;"
             Importance="High" />

    <Message Text="****** Command Line for referencing projects=%(ClCommandLineForReference.Identity)&#xA;" Importance="High" />
  </Target>
  
  <Target Name="_ValidatePathInfo"
        DependsOnTargets="GetProjectDirectories;GetClCommandLines;GetGeneratedFiles;GetProjectReferencesInfo">
    <ItemGroup>
      <Link Include="__Tempfile__" >
        <Temp>true</Temp>
      </Link>
    </ItemGroup>
    
    <ItemGroup>
      <AllPaths Include="%(_ProjectDirectories.IncludePath);%(_ProjectDirectories.FrameworkIncludePath);%(_ProjectDirectories.ReferencePath);%(_ProjectDirectories.ExcludePath)">
        <SourceLocaltion>ProjectDirectories</SourceLocaltion>
      </AllPaths>

      <AllPaths Include="$(ExecutablePath)" Exclude="$(Path)">
        <SourceLocaltion>ProjectDirectories</SourceLocaltion>
      </AllPaths>

      <AllPaths Include="$(LibraryPath)">
        <SourceLocaltion>ProjectDirectories</SourceLocaltion>
      </AllPaths>

      <AllPaths Include="%(ClCompile.AdditionalIncludeDirectories)">
        <SourceLocaltion>ClCompile.AdditionalIncludeDirectories</SourceLocaltion>
      </AllPaths>

      <AllPaths Include="%(ClCompile.AdditionalUsingDirectories)">
        <SourceLocaltion>ClCompile.AdditionalUsingDirectories</SourceLocaltion>
      </AllPaths>

      <AllPaths Include="@(ClCompile)" Condition="'%(ClCompile.ConfigurationOptions)' != 'true'">
        <SourceLocaltion>ClCompile</SourceLocaltion>
      </AllPaths>
      
      <AllPaths Include="%(Link.AdditionalLibraryDirectories)">
        <SourceLocaltion>Link.AdditionalLibrary</SourceLocaltion>
      </AllPaths>

      <AllPaths Remove="@(AllPaths)" Condition="Exists('%(AllPaths.FullPath)')"/>
    </ItemGroup>

    <Message Condition="'@(AllPaths)' == ''" Text="All Paths Validated." />
    <Message Condition="'@(AllPaths)' != ''" Text="****** @(AllPaths->Count()) missing path detected:" Importance="High" />
    <Message Condition="'@(AllPaths)' != ''" Text="Missing path: '%(AllPaths.FullPath)' from '%(AllPaths.SourceLocaltion)'" />

  </Target>

  <Target Name="_PerfIntellisenseInfo"
        DependsOnTargets="GetProjectDirectories;GetClCommandLines;GetClCommandLineForReference;GetGeneratedFiles;GetProjectReferencesInfo">
  </Target>

  <Target Name="_PrintResolvedProjectReferences"
      DependsOnTargets="ResolveProjectReferencesDesignTime">

    <Message Text="ProjectReference=%(ProjectReference.Identity)&#xA;
                   ReferenceOutputAssembly=%(ProjectReference.ReferenceOutputAssembly)&#xA;
                   OutputItemType=%(ProjectReference.OutputItemType)&#xA;"
             Importance="High" />

    <Message Text="_ResolvedNativeProjectReferencePaths=%(_ResolvedNativeProjectReferencePaths.Identity)&#xA;
                   ReferenceSourceTarget=%(_ResolvedNativeProjectReferencePaths.ReferenceSourceTarget)&#xA;
                   ReferenceOutputAssembly=%(_ResolvedNativeProjectReferencePaths.ReferenceOutputAssembly)&#xA;"
             Importance="High" />

    <Message Text="_ResolvedProjectReferencePaths=%(_ResolvedProjectReferencePaths.Identity)&#xA;
                   ReferenceSourceTarget=%(_ResolvedProjectReferencePaths.ReferenceSourceTarget)&#xA;
                   ReferenceOutputAssembly=%(_ResolvedProjectReferencePaths.ReferenceOutputAssembly)&#xA;"
             Importance="High" />

  </Target>

  <PropertyGroup>
    <BuildDependsOn>SetTelemetryEnvironmentVariables;$(BuildDependsOn)</BuildDependsOn>
    <RebuildDependsOn>SetTelemetryEnvironmentVariables;$(RebuildDependsOn)</RebuildDependsOn>
  </PropertyGroup>

  <!-- these env vars will be set for all toolsets (current and old) -->
  <Target Name="SetTelemetryEnvironmentVariables"
          Condition="'$(DesignTimeBuild)' != 'true'">
    <!-- used by vctip -->
    <SetEnv Name   ="VSTEL_SolutionSessionID"
            Value  ="$(VSTEL_SolutionSessionID)"
            Prefix ="false">
    </SetEnv>
    <SetEnv Name   ="VSTEL_CurrentSolutionBuildID"
            Value  ="$(VSTEL_CurrentSolutionBuildID)"
            Prefix ="false">
    </SetEnv>
    <SetEnv Name   ="VSTEL_ProjectID"
            Value  ="$(ProjectGuid)"
            Prefix ="false">
      <Output TaskParameter="OutputEnvironmentVariable" PropertyName="VSTEL_ProjectID"/>
    </SetEnv>
    
    <!-- used by BuildInsights-->
    <SetEnv Name   ="VSTEL_SolutionPath"
            Value  ="$(SolutionPath)"
            Prefix ="false">
    </SetEnv>
    <SetEnv Name   ="VSTEL_MSBuildProjectFullPath"
            Value  ="$(MSBuildProjectFullPath)"
            Prefix ="false" >
    </SetEnv>
  </Target>

 </Project>
