<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright (c) Microsoft Corporation.
  Licensed under the MIT License.

  This file will be consumed by ALL UWP C++ app projects (both inside
  and outside of this repo) that build on top of Microsoft.ReactNative.
  Do not make any changes here unless it applies to ALL such projects.
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <!-- Check that the correct props have already been imported. -->
  <Target Name="EnsureRnwExternalPropsLoadedTarget" BeforeTargets="PrepareForBuild" Condition="'$(RnwExternalPropsLoaded)'!='Microsoft.ReactNative.Uwp.CppApp.props'">
    <Warning Text="Property `RnwExternalPropsLoaded` was incorrectly set to '$(RnwExternalPropsLoaded)'. Please ensure your project imports 'Microsoft.ReactNative.Uwp.CppApp.props' before importing this prop sheet." />
  </Target>

  <!-- Import targets common to all projects. -->
  <Import Project="$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Common.targets" />

  <!-- Due to visual studio unconditionally showing references, we have to trick it by making it impossible for VS to find the reference differences between building as source and building as NuGet -->
  <Import Project="$(ReactNativeWindowsDir)PropertySheets\External\Microsoft.ReactNative.Cpp.ProjectReferences.props" Condition="!$(UseExperimentalNuget)" />
  <Import Project="$(ReactNativeWindowsDir)PropertySheets\External\Microsoft.ReactNative.Cpp.PackageReferences.props" Condition="$(UseExperimentalNuget)" />

  <ItemGroup>
    <PackageReference Include="Microsoft.Windows.CppWinRT" Version="$(CppWinRTVersion)" PrivateAssets="all" />
    <!-- WinUI package name and version are set by WinUI.props -->
    <PackageReference Include="$(WinUIPackageName)" Version="$(WinUIPackageVersion)" Condition="'$(OverrideWinUIPackage)'!='true'" />
    <!-- Hermes version is set by JSEngine.props -->
    <PackageReference Include="$(HermesPackageName)" Version="$(HermesVersion)" />
  </ItemGroup>

  <!-- The props file for bundling is not set up to be just defaults, it assumes to be run at the end of the project. -->
  <Import Project="$(ReactNativeWindowsDir)\PropertySheets\Bundle.props" />
  <Import Project="$(ReactNativeWindowsDir)\PropertySheets\Bundle.Cpp.targets"/>

  <Import Project="$(ReactNativeWindowsDir)\PropertySheets\Autolink.targets" />
  <Import Project="$(ProjectDir)\AutolinkedNativeModules.g.targets"
          Condition="Exists('$(ProjectDir)\AutolinkedNativeModules.g.targets')" />

  <Import Project="$(ReactNativeWindowsDir)\PropertySheets\Codegen.targets" />

  <Import Project="$(OutputPath)$(AssemblyName).Build.appxrecipe"
          Condition="Exists('$(OutputPath)$(AssemblyName).Build.appxrecipe') And '$(DeployLayout)'=='true'" />

  <Target Name="Deploy" Condition="'$(DeployLayout)'=='true'">
    <Error Condition="!Exists('$(OutputPath)$(AssemblyName).Build.appxrecipe')"
           Text="You must first build the project before deploying it" />
    <Copy SourceFiles="%(AppxPackagedFile.Identity)"
          DestinationFiles="$(OutputPath)Appx\%(AppxPackagedFile.PackagePath)" />
    <Copy SourceFiles="%(AppXManifest.Identity)"
          DestinationFiles="$(OutputPath)Appx\%(AppxManifest.PackagePath)"
          Condition="'%(AppxManifest.SubType)'!='Designer'"/>
    <Exec Command="powershell -NonInteractive -NoProfile -Command Add-AppxPackage -Register $(OutputPath)Appx\AppxManifest.xml"
          ContinueOnError="false" />
  </Target>

  <Import Project="$(ReactNativeWindowsDir)\PropertySheets\CppAppConsumeCSharpModule.targets" />
  <Import Project="$(ReactNativeWindowsDir)\PropertySheets\RequireSolution.targets" />
  <Import Project="$(ReactNativeWindowsDir)\PropertySheets\FixupRoslynCscWarnings.targets" />
  <Import Project="$(ReactNativeWindowsDir)\PropertySheets\OutputMSBuildProperties.targets" />

  <ItemDefinitionGroup>
    <Reference>
        <Private Condition="'$(ConfigurationType)' != 'Application'">false</Private>
    </Reference>
  </ItemDefinitionGroup>
</Project>
