<!--
***********************************************************************************************
Microsoft.Windows.UI.Xaml.Common.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.

Copyright (C) Microsoft Corporation. All rights reserved.
***********************************************************************************************
-->

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

    <Import Project="ImportBefore\*"/>

    <!-- Need the path to vcmeta.dll -->
    <PropertyGroup>
        <VCInstallDir Condition="'$(VCInstallDir)' == ''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\14.0\Setup\VC@ProductDir)</VCInstallDir>
        <VCInstallDir Condition="'$(VCInstallDir)' == ''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\Setup\VC@ProductDir)</VCInstallDir>
        <VCInstallDir Condition="'$(VCInstallDir)' == ''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VSWinExpress\14.0\Setup\VC@ProductDir)</VCInstallDir>
        <VCInstallDir Condition="'$(VCInstallDir)' == ''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VSWinExpress\14.0\Setup\VC@ProductDir)</VCInstallDir>

        <XAMLFingerprint Condition="'$(XAMLFingerprint)' == ''">true</XAMLFingerprint>
        <DisableXbfGeneration Condition="'$(DisableXbfGeneration)' == '' AND '$(TargetPlatformVersion)' == '8.0'">true</DisableXbfGeneration>
        <DisableXbfGeneration Condition="'$(DisableXbfGeneration)' == ''">false</DisableXbfGeneration>

        <XamlSavedStateFileName Condition="'$(XamlSavedStateFileName)' == ''">XamlSaveStateFile.xml</XamlSavedStateFileName>
        <XamlSavedStateFilePath>$(IntermediateOutputPath)\$(XamlSavedStateFileName)</XamlSavedStateFilePath>

        <XAMLFingerprintIgnorePaths Condition="'$(XAMLFingerprintIgnorePaths)'==''">
            @(ReferenceAssemblyPaths);
            $(WindowsSDK80Path)
        </XAMLFingerprintIgnorePaths>
    </PropertyGroup>

    <ItemGroup Condition="'$(BuildingInsideVisualStudio)'=='true'">
        <AvailableItemName Include="PRIResource" />
        <AvailableItemName Include="AppxManifest" />
        <AvailableItemName Include="ApplicationDefinition" />
        <AvailableItemName Include="Page" />
        <AvailableItemName Include="DesignData" />
        <AvailableItemName Include="DesignDataWithDesignTimeCreatableTypes" />
    </ItemGroup>

    <ItemGroup>
        <ProjectCapability Include="WindowsXaml"/>
        <ProjectCapability Include="WindowsXamlPage"/>
        <ProjectCapability Include="WindowsXamlCodeBehind"/>
        <ProjectCapability Include="WindowsXamlResourceDictionary"/>
        <ProjectCapability Include="WindowsXamlUserControl"/>
    </ItemGroup>

    <!-- For Managed Assemblies Create a XAML Roots Log -->
    <PropertyGroup Condition="'$(ManagedAssembly)' != 'false'">
        <XamlRootsLog>$(AssemblyName).xr.xml</XamlRootsLog>
    </PropertyGroup>

    <!-- Setting PRI index name.  The XAML compiler use this in the LoadComponent() string.
         It must match the name of the directoy the AppX Packaging system uses -->
    <PropertyGroup>
        <!-- Exe's don't have an PriIndexName -->
        <PriIndexName Condition="'$(AppxPackage)' == 'true'"></PriIndexName>
        <!-- Managed Dll's use the "safe" name of the project as the App Package Name -->
        <PriIndexName Condition="'$(AppxPackage)' != 'true' and '$(ManagedAssembly)' != 'false' and '$(OutputType)' != 'winmdobj'">$(TargetName)</PriIndexName>
        <!-- Winmd library targets (managed or native) use the default root namespace of the project for the App package name -->
        <PriIndexName Condition="'$(AppxPackage)' != 'true' and '$(ManagedAssembly)' != 'false' and '$(OutputType)' == 'winmdobj'">$(RootNamespace)</PriIndexName>
        <PriIndexName Condition="'$(AppxPackage)' != 'true' and '$(ManagedAssembly)' == 'false' and '$(RootNamespace)' != ''">$(RootNamespace)</PriIndexName>
        <!-- If RootNamespace is empty fall back to TargetName -->
        <PriIndexName Condition="'$(AppxPackage)' != 'true' and $(PriIndexName) == ''">$(TargetName)</PriIndexName>
    </PropertyGroup>

    <PropertyGroup>
        <AvailablePlatforms>$(AvailablePlatforms),ARM</AvailablePlatforms>

        <!-- this Property is used only for the Managed build.
            See Microsoft.Windows.UI.Xaml.Cpp.Targets for Native build rules -->
        <PrepareResourcesDependsOn>
            ResolveKeySource;
            MarkupCompilePass1;
            XamlPreCompile;
            MarkupCompilePass2;
            $(PrepareResourcesDependsOn)
        </PrepareResourcesDependsOn>

        <Prefer32Bit Condition="'$(Prefer32Bit)' == '' and ('$(OutputType)' == 'exe' or '$(OutputType)' == 'winexe' or '$(OutputType)' == 'appcontainerexe')">true</Prefer32Bit>
        <HighEntropyVA Condition="'$(HighEntropyVA)' == ''">true</HighEntropyVA>
        <SubsystemVersion Condition="'$(SubsystemVersion)' == '' and ('$(PlatformTarget)' == 'ARM' or '$(OutputType)' == 'appcontainerexe' or '$(OutputType)' == 'winmdobj')">6.02</SubsystemVersion>
        <SubsystemVersion Condition="'$(SubsystemVersion)' == ''">6.00</SubsystemVersion>

        <OnXamlPreCompileErrorTarget Condition="'$(OnXamlPreCompileErrorTarget)' == ''">_OnXamlPreCompileError</OnXamlPreCompileErrorTarget>

        <!-- Use Intermediate dir if XamlGeneratedOutputPath is not defined -->
        <XamlGeneratedOutputPath Condition="'$(XamlGeneratedOutputPath)' == ''">$(IntermediateOutputPath)</XamlGeneratedOutputPath>
    </PropertyGroup>

    <UsingTask TaskName="Microsoft.Windows.UI.Xaml.Build.Tasks.CompileXaml"                  AssemblyFile="Microsoft.Windows.UI.Xaml.81.Build.Tasks.dll" />
    <UsingTask TaskName="Microsoft.Windows.UI.Xaml.Build.Tasks.AddDefaultXamlLinkMetadata"   AssemblyFile="Microsoft.Windows.UI.Xaml.81.Build.Tasks.dll" />
    <UsingTask TaskName="Microsoft.Windows.UI.Xaml.Build.Tasks.GetXamlCppIncludeDirectories" AssemblyFile="Microsoft.Windows.UI.Xaml.81.Build.Tasks.dll" />

    <PropertyGroup>
        <!--If the path to the sign tool is not set, assume the SDK path -->
        <SignToolPath Condition="'$(SignToolPath)' == ''">$(FrameworkSDKRoot)bin</SignToolPath>

        <!--Integration with packaging for GeneratedXamlFilesOutputGroupOutput -->
        <IncludeCustomOutputGroupForPackaging>true</IncludeCustomOutputGroupForPackaging>
    </PropertyGroup>

    <ItemGroup>
        <XamlIntermediateAssembly Condition="'$(ManagedAssembly)'!='false'" Include="$(XamlGeneratedOutputPath)intermediatexaml\$(TargetName)$(TargetExt)"/>
        <XamlIntermediateAssembly Condition="'$(ManagedAssembly)'=='false'" Include="$(OutputPath)\$(TargetName).winmd"/>
    </ItemGroup>

    <!--
    ============================================================
    Adds all XAML Pages to the $(Resource) collection
    ============================================================
    -->
    <ItemGroup Condition=" '$(ManagedAssembly)'=='' ">
        <!-- Add XAML Page items to $(Resource) -->
        <Resource Include="@(Page)" />
        <Resource Include="@(ApplicationDefinition)" />
    </ItemGroup>

    <!-- Manifest metadata items.                       -->
    <!-- See Microsoft.AppxPackage.targets for details. -->
    <ItemGroup Label="AppxManifestMetadata">
        <AppxManifestMetadata Include="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\$(TargetPlatformVersion)\Microsoft.Windows.UI.Xaml.81.Build.Tasks.dll" />
    </ItemGroup>

    <PropertyGroup>
        <MarkupCompilePass1DependsOn>
            GetXamlCppIncludeDirectories;
            $(GetXamlCppIncludeDirectories)
        </MarkupCompilePass1DependsOn>

        <MarkupCompilePass2DependsOn>
            GetXamlCppIncludeDirectories;
            $(GetXamlCppIncludeDirectories)
        </MarkupCompilePass2DependsOn>

        <Prep_ComputeProcessXamlFilesDependsOn>
            GetXamlCppIncludeDirectories;
            $(Prep_ComputeProcessXamlFilesDependsOn)
        </Prep_ComputeProcessXamlFilesDependsOn>
    </PropertyGroup>

    <!-- In order for the XAML compiler to generated the correct relative paths for #includes in
         the generated C++ code it needs to know the AdditionalIncludeDirectories of all the .cpp
         files are DependentUpon XAML files.-->
    <Target Name="GetXamlCppIncludeDirectories" Condition="'$(ManagedAssembly)'=='false' and '$(XamlCppIncludeDirectories)' == ''">
        <GetXamlCppIncludeDirectories ClCompile="@(ClCompile)">
            <Output PropertyName="XamlCppIncludeDirectories" TaskParameter="ComputedIncludeDirectories" />
        </GetXamlCppIncludeDirectories>
    </Target>

    <!-- 
    ================================================================
                        DesignTimeMarkupCompilation
                        
    Support for the Intellisense build
    ================================================================
     -->
    <PropertyGroup>
        <CoreCompileDependsOn Condition="'$(BuildingInsideVisualStudio)' == 'true' ">
            DesignTimeMarkupCompilation;
            $(CoreCompileDependsOn)
        </CoreCompileDependsOn>
    </PropertyGroup>

    <Target Name="DesignTimeMarkupCompilation">
        <!-- BuildingProject is used in Managed builds (always true in Native) -->
        <!-- DesignTimeBuild is used in Native builds (always false in Managed) -->
        <CallTarget Condition="'$(BuildingProject)' != 'true' Or $(DesignTimeBuild) == 'true'" Targets="DesignTimeMarkupCompilationCT" />
    </Target>

    <!-- A copy of the first pass, without the WarningLevel manipulation -->
    <Target Name="DesignTimeMarkupCompilationCT"
          DependsOnTargets="$(MarkupCompilePass1DependsOn)"
          Condition="'@(Page)' != '' Or '@(ApplicationDefinition)' != '' " >

        <MakeDir Condition="'$(ManagedAssembly)'!='false'" Directories="$(XamlGeneratedOutputPath)intermediatexaml\" />

        <CompileXaml
                LanguageSourceExtension="$(DefaultLanguageSourceExtension)"
                Language="$(Language)"
                RootNamespace="$(RootNamespace)"
                XamlPages="@(Page)"
                XamlApplications="@(ApplicationDefinition)"
                PriIndexName="$(PriIndexName)"
                ProjectName="$(MsBuildProjectName)"
                IsPass1="True"
                CodeGenerationControlFlags="$(XamlCodeGenerationControlFlags)"
                CIncludeDirectories="$(XamlCppIncludeDirectories)"
                ProjectPath="$(MSBuildProjectFullPath)"
                OutputPath="$(XamlGeneratedOutputPath)"
                OutputType="$(OutputType)"
                ReferenceAssemblyPaths="@(ReferenceAssemblyPaths)"
                ReferenceAssemblies="@(ReferencePath)"
                ForceSharedStateShutdown="False"
                ContinueOnError="True"
                CompileMode="DesignTimeBuild"
                XAMLFingerprint="$(XAMLFingerprint)"
                FingerprintIgnorePaths="$(XAMLFingerprintIgnorePaths)"
                VCInstallDir="$(VCInstallDir)"
                SavedStateFile="$(XamlSavedStateFilePath)"
                SuppressWarnings="$(SuppressXamlWarnings)"
            >
            <Output Condition=" '$(ManagedAssembly)'!='false' " ItemName="Compile"   TaskParameter="GeneratedCodeFiles" />

            <!--
      Add to the list of files written.
      It is used in Microsoft.Common.Targets for a next clean build 
      -->
            <Output ItemName="FileWrites" TaskParameter="GeneratedCodeFiles" />
            <Output ItemName="FileWrites" TaskParameter="GeneratedXamlFiles" />
            <Output ItemName="_GeneratedCodeFiles" TaskParameter="GeneratedCodeFiles" />
        </CompileXaml>

        <ItemGroup>
            <FileWrites Include="$(XamlSavedStateFilePath)" />
        </ItemGroup>

        <Message Text="(Out) ISenseCodeFiles: '@(_GeneratedCodeFiles)'" />
        <Message Text="(Out) ISenseXamlFiles: '@(_GeneratedXamlFiles)'" />
        <Message Text="(Out) ClCompile: '@(ClCompile)'" Condition="'%(ClCompile.CompilerIteration)' != 'XamlGenerated'"/>
        <Message Text="(Out) Compile: '@(Compile)'" />
    </Target>

    <!--   
    ================================================================
                         MarkupCompilePass1
    ================================================================
    -->

    <Target Name="MarkupCompilePass1"
          DependsOnTargets="$(MarkupCompilePass1DependsOn)"
          Condition="'@(Page)' != '' Or '@(ApplicationDefinition)' != '' " >

        <MakeDir Condition="'$(ManagedAssembly)'!='false'" Directories="$(XamlGeneratedOutputPath)intermediatexaml\" />

        <CompileXaml
                LanguageSourceExtension="$(DefaultLanguageSourceExtension)"
                Language="$(Language)"
                RootNamespace="$(RootNamespace)"
                XamlPages="@(Page)"
                XamlApplications="@(ApplicationDefinition)"
                PriIndexName="$(PriIndexName)"
                ProjectName="$(MsBuildProjectName)"
                IsPass1="True"
                CodeGenerationControlFlags="$(XamlCodeGenerationControlFlags)"
                ProjectPath="$(MSBuildProjectFullPath)"
                CIncludeDirectories="$(XamlCppIncludeDirectories)"
                OutputPath="$(XamlGeneratedOutputPath)"
                OutputType="$(OutputType)"
                ReferenceAssemblyPaths="@(ReferenceAssemblyPaths)"
                ReferenceAssemblies="@(ReferencePath)"
                ForceSharedStateShutdown="False"
                CompileMode="RealBuildPass1"
                XAMLFingerprint="$(XAMLFingerprint)"
                FingerprintIgnorePaths="$(XAMLFingerprintIgnorePaths)"
                VCInstallDir="$(VCInstallDir)"
                SavedStateFile="$(XamlSavedStateFilePath)"
                SuppressWarnings="$(SuppressXamlWarnings)"
             >

            <Output Condition=" '$(ManagedAssembly)'!='false' " ItemName="Compile"   TaskParameter="GeneratedCodeFiles" />

            <!--
      FileWrites is used in Microsoft.Common.Targets for "Clean" build 
      -->
            <Output ItemName="FileWrites" TaskParameter="GeneratedCodeFiles" />
            <Output ItemName="FileWrites" TaskParameter="GeneratedXamlFiles" />
            <Output ItemName="FileWrites" TaskParameter="GeneratedXbfFiles" />
            <Output ItemName="_GeneratedCodeFiles" TaskParameter="GeneratedCodeFiles" />
        </CompileXaml>

        <ItemGroup>
            <FileWrites Include="$(XamlSavedStateFilePath)" />
        </ItemGroup>

        <Message Text="(Out) GeneratedCodeFiles: '@(_GeneratedCodeFiles)'" />
        <Message Text="(Out) ClCompile: '@(ClCompile)'" Condition="'$(ManagedAssembly)'=='false' and '%(ClCompile.CompilerIteration)'!='XamlGenerated'"/>
        <Message Text="(Out) Compile: '@(Compile)'" Condition="'$(ManagedAssembly)'!='false'"/>

        <PropertyGroup>
            <PrevWarningLevel>$(WarningLevel)</PrevWarningLevel>
            <WarningLevel Condition="'$(SuppressWarningsInPass1)'=='true'">0</WarningLevel>
        </PropertyGroup>
    </Target>

    <!--   
    ================================================================
                         MarkupCompilePass2
    ================================================================
    -->

    <Target Name="MarkupCompilePass2"
            DependsOnTargets="$(MarkupCompilePass2DependsOn)"
            Condition="'@(Page)' != '' Or '@(ApplicationDefinition)' != '' " >

        <PropertyGroup>
            <WarningLevel>$(PrevWarningLevel)</WarningLevel>
            <WarningLevel Condition="'$(WarningLevel)' == '' and '$(ExplicitResetWarningSuppression)' == 'true'">1</WarningLevel>
        </PropertyGroup>

        <!-- The Name of the Local Assembly in Managed and Native -->
        <PropertyGroup>
            <LocalAssembly Condition="'$(LocalAssembly)' == '' and Exists(@(XamlIntermediateAssembly))">
                @(XamlIntermediateAssembly->'%(Identity)')
            </LocalAssembly>
        </PropertyGroup>

        <CallTarget Targets="SDKRedistOutputGroup" Condition="'$(IncludeSDKRedistOutputGroup)' == 'true'">
            <Output TaskParameter="TargetOutputs" ItemName="_SDKRedistOutputGroupOutput_xaml"/>
        </CallTarget>
        <ItemGroup>
            <SdkXamlItems Include="@(_SDKRedistOutputGroupOutput_xaml)" Condition="'%(Extension)'=='.xaml'" />
        </ItemGroup>

        <ItemGroup>
            <!-- C++ provides a filtered Item that eliminates any Managed Assemblies on the ReferencePath (from SDKs for example) -->
            <XamlReferencesToCompile Condition="'$(Language)'=='C++'" Include="@(WinMDReferenceToCompile)" />
            <XamlReferencesToCompile Condition="'$(Language)'!='C++'" Include="@(ReferencePath)" />
        </ItemGroup>

        <CompileXaml
                LanguageSourceExtension="$(DefaultLanguageSourceExtension)"
                Language="$(Language)"
                RootNamespace="$(RootNamespace)"
                XamlPages="@(Page)"
                XamlApplications="@(ApplicationDefinition)"
                SdkXamlPages="@(SdkXamlItems)"
                PriIndexName="$(PriIndexName)"
                ProjectName="$(MsBuildProjectName)"
                IsPass1="False"
                DisableXbfGeneration="$(DisableXbfGeneration)"
                CodeGenerationControlFlags="$(XamlCodeGenerationControlFlags)"
                ClIncludeFiles="@(ClInclude)"
                CIncludeDirectories="$(XamlCppIncludeDirectories)"
                LocalAssembly="$(LocalAssembly)"
                ProjectPath="$(MSBuildProjectFullPath)"
                OutputPath="$(XamlGeneratedOutputPath)"
                OutputType="$(OutputType)"
                ReferenceAssemblyPaths="@(ReferenceAssemblyPaths)"
                ReferenceAssemblies="@(XamlReferencesToCompile)"
                ForceSharedStateShutdown="False"
                CompileMode="RealBuildPass2"
                XAMLFingerprint="$(XAMLFingerprint)"
                FingerprintIgnorePaths="$(XAMLFingerprintIgnorePaths)"
                VCInstallDir="$(VCInstallDir)"
                SavedStateFile="$(XamlSavedStateFilePath)"
                RootsLog="$(XamlRootsLog)"
                SuppressWarnings="$(SuppressXamlWarnings)"
                >
            <Output Condition=" '$(ManagedAssembly)'!='false' " ItemName="Compile"   TaskParameter="GeneratedCodeFiles" />
            <Output Condition=" '$(ManagedAssembly)'=='false' " ItemName="XamlGFiles" TaskParameter="GeneratedCodeFiles" />

            <!--
      FileWrites is used in Microsoft.Common.Targets for "Clean" build 
      -->
            <Output ItemName="FileWrites" TaskParameter="GeneratedCodeFiles" />
            <Output ItemName="FileWrites" TaskParameter="GeneratedXamlFiles" />
            <Output ItemName="FileWrites" TaskParameter="GeneratedXbfFiles" />
            <Output ItemName="_GeneratedCodeFiles" TaskParameter="GeneratedCodeFiles" />
            <Output ItemName="_GeneratedXamlFiles" TaskParameter="GeneratedXamlFiles" />
            <Output ItemName="_GeneratedXbfFiles" TaskParameter="GeneratedXbfFiles" />
        </CompileXaml>

        <ItemGroup>
            <FileWrites Include="$(XamlSavedStateFilePath)" />
            <FileWrites Condition="'$(XamlRootsLog)' != ''" Include="$(XamlRootsLog)" />
        </ItemGroup>

        <Message Text="(Out) GeneratedCodeFiles: '@(_GeneratedCodeFiles)'" />
        <Message Text="(Out) GeneratedXamlFiles: '@(_GeneratedXamlFiles)'" />
        <Message Text="(Out) GeneratedXbfFiles: '@(_GeneratedXbfFiles)'" />
        <Message Text="(Out) ClCompile: '@(ClCompile)'" Condition="'$(ManagedAssembly)'=='false'"/>
        <Message Text="(Out) Compile: '@(Compile)'" Condition="'$(ManagedAssembly)'!='false'"/>
    </Target>

    <Target Name="_OnXamlPreCompileError"
            DependsOnTargets="$(_OnXamlPrecompileErrorDependsOn)" >

        <CompileXaml
                ProjectPath="$(MSBuildProjectFullPath)"
                Language="$(Language)"
                LanguageSourceExtension="$(DefaultLanguageSourceExtension)"
                OutputPath="$(XamlGeneratedOutputPath)"
                ReferenceAssemblies="@(ReferencePath)"
                ReferenceAssemblyPaths="@(ReferenceAssemblyPaths)"
                XamlPages="@(Page)"
                XamlApplications="@(ApplicationDefinition)"
                ForceSharedStateShutdown="True"
                CompileMode="OnErrorShutdown"
                SavedStateFile="$(XamlSavedStateFilePath)"
                >
        </CompileXaml>
    </Target>

    <Target Name="Prep_ComputeProcessXamlFiles"
            Condition="'@(ApplicationDefinition)'!='' or '@(Page)'!=''"
            DependsOnTargets="$(Prep_ComputeProcessXamlFilesDependsOn)" >

        <!-- collect all the XAML pages from the Project file into one Item -->
        <ItemGroup>
            <AllProjectXamlPages Condition="'%(ApplicationDefinition.ExcludedFromBuild)'!='true'" Include="@(ApplicationDefinition)" />
            <AllProjectXamlPages Condition="'%(Page.ExcludedFromBuild)'!='true'" Include="@(Page)" />
        </ItemGroup>

        <!-- For ttems are outside the project cone Link metadata tells us what the apparent project path should be.
         C++ doesn't use Link data, so for C++ add implied DefaultXamlLink metadata based on the Include Path -->
        <AddDefaultXamlLinkMetadata Condition="'$(ManagedAssembly)'=='false'"
                                    ProjectPath="$(ProjectPath)"
                                    XamlPages="@(AllProjectXamlPages)"
                                    CIncludeDirectories ="$(XamlCppIncludeDirectories)">
            <Output TaskParameter="OutputItems" ItemName="_Temp" />
        </AddDefaultXamlLinkMetadata>

        <!-- Remove the Items named in _Temp, then add the actual items from _Temp, then clear _Temp  -->
        <ItemGroup>
            <AllProjectXamlPages Remove="@(_Temp)" />
            <AllProjectXamlPages Include="@(_Temp)" />
            <_Temp Remove="@(_Temp)" />
        </ItemGroup>

        <!-- transfer the DefaultXamlLink data to the Link attribute -->
        <ItemGroup>
            <AllProjectXamlPages Condition="'%(AllProjectXamlPages.DefaultXamlLink)'!=''">
                <Link>%(AllProjectXamlPages.DefaultXamlLink)</Link>
            </AllProjectXamlPages>
        </ItemGroup>

        <!-- Compute the Generated XAML source path and the bin dir Destination path -->
        <!-- If there is a Link use that, otherwise use the Given path from the Project file Item -->
        <ItemGroup>
            <GeneratedXamlSrc0 Condition="'%(AllProjectXamlPages.Link)'!=''" Include="@(AllProjectXamlPages->'$(XamlGeneratedOutputPath)%(Link)')" />
            <GeneratedXamlSrc0 Condition="'%(AllProjectXamlPages.Link)'==''" Include="@(AllProjectXamlPages->'$(XamlGeneratedOutputPath)%(Identity)')" />

            <GeneratedXamlDest0 Condition="'%(AllProjectXamlPages.Link)'!=''" Include="@(AllProjectXamlPages->'$(OutputPath)\%(Link)')" />
            <GeneratedXamlDest0 Condition="'%(AllProjectXamlPages.Link)'==''" Include="@(AllProjectXamlPages->'$(OutputPath)\%(Identity)')" />
        </ItemGroup>

        <!-- Swap in the XBF suffix if appropriate. -->
        <ItemGroup Condition="'$(DisableXbfGeneration)' == 'true'">
            <GeneratedXamlSrc Include="@(GeneratedXamlSrc0)" />
            <GeneratedXamlDest Include="@(GeneratedXamlDest0)" />
        </ItemGroup>
        <ItemGroup Condition="'$(DisableXbfGeneration)' != 'true'">
            <GeneratedXamlSrc Include="%(GeneratedXamlSrc0.RelativeDir)%(GeneratedXamlSrc0.Filename).xbf" />
            <GeneratedXamlDest Include="%(GeneratedXamlDest0.RelativeDir)%(GeneratedXamlDest0.Filename).xbf" />
        </ItemGroup>

        <!-- if we converted SDK XAML into XBF, add the XBF to the list, and remove the XAML from the list -->
        <ItemGroup Condition="'$(DisableXbfGeneration)' != 'true' and '@(SdkXamlItems)' != ''">
            <GeneratedSdkXamlSrc0 Include="@(SdkXamlItems->'$(XamlGeneratedOutputPath)%(TargetPath)')" />
            <GeneratedSdkXamlDest0 Include="@(SdkXamlItems->'$(OutputPath)\%(TargetPath)')" />

            <GeneratedXamlSrc Include="%(GeneratedSdkXamlSrc0.RelativeDir)%(GeneratedSdkXamlSrc0.Filename).xbf" />
            <GeneratedXamlDest Include="%(GeneratedSdkXamlDest0.RelativeDir)%(GeneratedSdkXamlDest0.Filename).xbf" />
            <RemoveSdkFilesFromAppxPackage Include="@(SdkXamlItems)" />
        </ItemGroup>

        <ItemGroup Condition="'$(XamlRootsLog)' != ''">
            <GeneratedXamlSrc Include="$(XamlGeneratedOutputPath)\$(XamlRootsLog)" />
            <GeneratedXamlDest Include="$(OutputPath)\$(XamlRootsLog)" />
        </ItemGroup>

        <Message Importance="low" Text="(Out) Prep_GeneratedXamlSrc == @(GeneratedXamlSrc)" />
        <Message Importance="low" Text="(Out) Prep_GeneratedXamlDest == @(GeneratedXamlDest)" />
    </Target>

    <!-- if $GenerateLibraryLayout is True this is skipped and see the PrepareLibraryLayout target -->
    <Target Name="CopyGeneratedXaml" BeforeTargets="CopyFilesToOutputDirectory" DependsOnTargets="Prep_ComputeProcessXamlFiles"
              Condition="'$(GenerateLibraryLayout)' != 'true'">
        <Copy
            SourceFiles="@(GeneratedXamlSrc)"
            DestinationFiles="@(GeneratedXamlDest)"
            SkipUnchangedFiles="$(SkipCopyUnchangedFiles)"
            OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
            Retries="$(CopyRetryCount)"
            RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
            UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)"
        />
        <ItemGroup>
            <FileWrites Include="@(GeneratedXamlDest)" />
        </ItemGroup>
    </Target>

    <Target Name="ComputeProcessXamlFiles" Returns="@(ProcessedXamlFiles)" DependsOnTargets="Prep_ComputeProcessXamlFiles">
        <ItemGroup >
            <!-- In the normal (non-SDK) build, AppX Packaging picks up the files from the bin aka OutputPath folder -->
            <ProcessedXamlFiles Condition="'$(GenerateLibraryLayout)' != 'true'" Include="@(GeneratedXamlDest)" />

            <!-- In the SDK build, AppX Packaging picks up the files from the XamlGeneratedOutput folder -->
            <!-- For SDK builds include both the XAML and XBF -->
            <ProcessedXamlFiles Condition="'$(GenerateLibraryLayout)' == 'true'" Include="@(GeneratedXamlSrc)" />
            <ProcessedXamlFiles Condition="'$(GenerateLibraryLayout)' == 'true' and '$(DisableXbfGeneration)' != 'true'"
                                Include="@(GeneratedXamlSrc0)" />
        </ItemGroup>
        <Message Importance="Low" Text="(Out) GeneratedXamlDest == @(GeneratedXamlDest)" />
        <Message Importance="Low" Text="(Out) GeneratedXamlSrc == @(GeneratedXamlSrc)" />
        <Message Text="(Out) ProcessedXamlFiles == @(ProcessedXamlFiles)" />
    </Target>

    <Target Name="CustomOutputGroupForPackaging"
            DependsOnTargets="ComputeProcessXamlFiles"
            Returns="@(CustomOutputGroupForPackagingOutput)"
            >
        <ItemGroup>
            <ProcessedXamlFilesFullPath Include="@(ProcessedXamlFiles->'%(FullPath)')" />
        </ItemGroup>
        <PropertyGroup>
            <XamlPackagingRootFolder Condition="'$(GenerateLibraryLayout)' == 'true'">$(XamlGeneratedOutputPath)</XamlPackagingRootFolder>
            <XamlPackagingRootFolder Condition="'$(GenerateLibraryLayout)' != 'true'">$(OutputPath)\</XamlPackagingRootFolder>
        </PropertyGroup>

        <AssignTargetPath Files="@(ProcessedXamlFilesFullPath)" RootFolder="$(XamlPackagingRootFolder)">
            <Output TaskParameter="AssignedFiles" ItemName="CustomOutputGroupForPackagingOutput" />
        </AssignTargetPath>

        <Message Text="(Out) Project='$(MsBuildProjectName)' ProcessedXamlFiles == @(ProcessedXamlFiles)" />
        <Message Text="(Out) XamlPackagingRootFolder == $(XamlPackagingRootFolder)" />
        <Message Text="(Out) ProcessedXamlFilesFullPath == @(ProcessedXamlFilesFullPath)" />
        <Message Text="(Out) Project='$(MsBuildProjectName)' CustomOutputGroupForPackagingOutput == @(CustomOutputGroupForPackagingOutput)" />

    </Target>

    <PropertyGroup>
        <PrepareLibraryLayoutDependsOn>
            GetPackagingOutputs;
            $(PrepareLibraryLayoutDependsOn)
        </PrepareLibraryLayoutDependsOn>
    </PropertyGroup>

    <!-- This builds the Bin Folder for DLL's that wish to have the SDK type layout -->
    <Target Name="PrepareLibraryLayout"
            Condition="'$(GenerateLibraryLayout)' == 'true'"
            DependsOnTargets="$(PrepareLibraryLayoutDependsOn)"
            BeforeTargets="CopyFilesToOutputDirectory"
            >

        <ItemGroup>
            <_LayoutFile Include="@(PackagingOutputs)" Condition="'%(OutputGroup)' == 'ContentFilesProjectOutputGroup'" />
            <_LayoutFile Include="@(PackagingOutputs)" Condition="'%(OutputGroup)' == 'CustomOutputGroupForPackaging'" />
        </ItemGroup>

        <Copy SourceFiles="@(_LayoutFile)"
              DestinationFiles="@(_LayoutFile->'$(OutputPath)\%(TargetPath)')"
              SkipUnchangedFiles="$(SkipCopyUnchangedFiles)"
              OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
              Retries="$(CopyRetryCount)"
              RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
              UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)"
              />
    </Target>

    <!--
    ============================================================
    Properties and Targets Common to Managed .NETCore projects
    ============================================================
    -->

    <!--
      The ImplicitlyExpandTargetFramework target will expand all 
      of the dll reference assemblies in the TargetFrameworkDirectory 
      for the project and place the items into the ReferencePath itemgroup 
      which contains resolved items.
    -->
    <PropertyGroup>
        <ResolveReferencesDependsOn>
            $(ResolveReferencesDependsOn);
            ImplicitlyExpandTargetFramework;
            ImplicitlyExpandTargetPlatform
        </ResolveReferencesDependsOn>

        <ImplicitlyExpandTargetFrameworkDependsOn>
            $(ImplicitlyExpandTargetFrameworkDependsOn);
            GetReferenceAssemblyPaths
        </ImplicitlyExpandTargetFrameworkDependsOn>
    </PropertyGroup>

    <Target Name="ImplicitlyExpandTargetFramework"
        Condition="'$(ImplicitlyExpandTargetFramework)' == 'true'"
        DependsOnTargets="$(ImplicitlyExpandTargetFrameworkDependsOn)"
    >
        <ItemGroup>
            <ReferenceAssemblyPaths Include="$(_TargetFrameworkDirectories)"/>
            <ReferencePath Include="%(ReferenceAssemblyPaths.Identity)*.dll">
                <WinMDFile>false</WinMDFile>
                <CopyLocal>false</CopyLocal>
                <ReferenceGroupingDisplayName>.NET for Windows Store apps</ReferenceGroupingDisplayName>
                <ReferenceGrouping>$(TargetFrameworkMoniker)</ReferenceGrouping>
                <ResolvedFrom>ImplicitlyExpandTargetFramework</ResolvedFrom>
                <IsSystemReference>True</IsSystemReference>
            </ReferencePath>
        </ItemGroup>

        <Message Importance="Low" Text="TargetMonikerDisplayName: $(TargetFrameworkMonikerDisplayName) ReferenceAssemblyPaths: @(ReferenceAssemblyPaths)"/>

        <Message Importance="Low" Text="Including @(ReferencePath)"
          Condition="'%(ReferencePath.ResolvedFrom)' == 'ImplicitlyExpandTargetFramework'"/>

        <ItemGroup>
            <_ResolveAssemblyReferenceResolvedFiles Include="@(ReferencePath)"
              Condition="'%(ReferencePath.ResolvedFrom)' == 'ImplicitlyExpandTargetFramework'"/>
        </ItemGroup>
    </Target>

    <!--
      The ImplicitlyExpandTargetPlatform target will expand all
      of the winmd files in the windowsSDK and add them the the
      ReferencePath item which is the itemgroup which contains
      resolved items.
    -->
    <Target Name="ImplicitlyExpandTargetPlatform"
       Condition="'$(ImplicitlyExpandTargetPlatform)' == 'true'"
    >
        <ItemGroup>
            <ReferencePath Include="$(TargetPlatformWinMDLocation)\*.winmd">
                <WinMDFile>true</WinMDFile>
                <CopyLocal>false</CopyLocal>
                <ReferenceGrouping>$(TargetPlatformMoniker)</ReferenceGrouping>
                <ReferenceGroupingDisplayName>$(TargetPlatformDisplayName)</ReferenceGroupingDisplayName>
                <ResolvedFrom>ImplicitlyExpandTargetPlatform</ResolvedFrom>
                <IsSystemReference>True</IsSystemReference>
            </ReferencePath>
        </ItemGroup>

        <Warning Condition="!Exists($(TargetPlatformWinMDLocation))"
          Text="The path to the $(TargetPlatformIdentifier) SDK [$(TargetPlatformWinMDLocation)] was not found!"/>

        <Message Importance="Low" Text="Including @(ReferencePath)"
          Condition="'%(ReferencePath.ResolvedFrom)' == 'ImplicitlyExpandTargetPlatform'"/>

        <ItemGroup>
            <_ResolveAssemblyReferenceResolvedFiles Include="@(ReferencePath)"
              Condition="'%(ReferencePath.ResolvedFrom)' == 'ImplicitlyExpandTargetPlatform'"/>
        </ItemGroup>
    </Target>

    <!-- 
      Enable warning when referenced projects have higher version than the current project
      for Windows Store projects 
    -->
    <PropertyGroup>
        <FindInvalidProjectReferences Condition="'$(TargetPlatformIdentifier)' == 'Windows' and 
                                              '$(TargetPlatformVersion)' &gt;= '8.0'">true</FindInvalidProjectReferences>
    </PropertyGroup>

    <!-- 
      Enable warning when referenced ESDKs do not have MaxPlatformVersion 
      specified for Windows Store projects 
    -->
    <PropertyGroup>
        <SDKReferenceWarnOnMissingMaxPlatformVersion Condition="'$(SDKReferenceWarnOnMissingMaxPlatformVersion)' == '' and 
                                                             '$(TargetPlatformIdentifier)' == 'Windows' and 
                                                             '$(TargetPlatformVersion)' &gt;= '8.0'">true</SDKReferenceWarnOnMissingMaxPlatformVersion>
    </PropertyGroup>


    <Import Project="ImportAfter\*"/>

</Project>
