<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup Label="WinUI3 versioning">

    <!--
      Internal versions are typically only located at: https://microsoft.visualstudio.com/DefaultCollection/ProjectReunion/_artifacts/feed/Project.Reunion.nuget.internal/NuGet/Microsoft.WindowsAppSDK/versions
      For local testing of internal versions, modify WinUI3ExperimentalVersion, and comment out the additional nuget source in NuGet.Config
      When this version is updated, be sure to update the default for the enableInternalFeed parameter of /.ado/templates/enable-experimental-winui3.yml
    -->
    <WinUI3ExperimentalVersion Condition="'$(WinUI3ExperimentalVersion)'==''">2.0.0-experimental3</WinUI3ExperimentalVersion>
    <!-- This value is also used by the CLI, see /packages/@react-native-windows/cli/.../autolinkWindows.ts -->
    <WinUI3Version Condition="'$(WinUI3Version)'=='' AND '$(UseExperimentalWinUI3)'=='true'">$(WinUI3ExperimentalVersion)</WinUI3Version>
    <WinUI3Version Condition="'$(WinUI3Version)'==''">1.8.260508005</WinUI3Version>
    <!-- This is needed to prevent build errors with WinAppSDK >= 1.7 trying to double build WindowsAppRuntimeAutoInitializer.cpp -->
    <WindowsAppSdkAutoInitialize Condition="'$(WindowsAppSdkAutoInitialize)'=='' And $([MSBuild]::VersionGreaterThan('$(WinUI3Version)', '1.7.0'))">false</WindowsAppSdkAutoInitialize>
  </PropertyGroup>

  <PropertyGroup Label="WinUI2x versioning">
		<!--This value is also used by the CLI, see /packages/@react-native-windows/cli/.../autolinkWindows.ts -->
    <WinUI2xVersion Condition="'$(WinUI2xVersion)'==''">2.8.0</WinUI2xVersion>
  </PropertyGroup>

  <PropertyGroup Label="XamlGuard">
    <!-- Setting DisableXamlGuard to true will disable the code which prevents mixing WinUI2 and WinUI3 in the same process. -->
    <DisableXamlGuard Condition="'$(DisableXamlGuard)'==''">false</DisableXamlGuard>
  </PropertyGroup>

  <PropertyGroup Condition="'$(UseWinUI3)'=='true'">
    <WinUIPackageName>Microsoft.WindowsAppSDK</WinUIPackageName>
    <WinUIPackageVersion>$(WinUI3Version)</WinUIPackageVersion>
    <WinUIPackageProps/>

    <!-- Enlighten C# code about WinUI3 -->
    <DefineConstants Condition="'$(UseWinUI3)'=='true'">USE_WINUI3;$(DefineConstants)</DefineConstants>

    <IsWinUIAlpha Condition="'$(IsWinUIAlpha)' == ''">true</IsWinUIAlpha>
    <WindowsKitsPath Condition="'$(IsWinUIAlpha)' == 'true'">WinUI-Alpha-Projects-Don-t-Use-SDK-Xaml-Tools</WindowsKitsPath>
  </PropertyGroup>

  <PropertyGroup Condition="'$(UseWinUI3)'!='true'">
    <WinUIPackageName>Microsoft.UI.Xaml</WinUIPackageName>
    <WinUIPackageVersion>$(WinUI2xVersion)</WinUIPackageVersion>
  </PropertyGroup>

  <ItemDefinitionGroup Condition="'$(UseWinUI3)'=='true'">
    <!-- Enlighten C++ code about WinUI3 -->
    <ClCompile>
      <PreprocessorDefinitions>USE_WINUI3;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <PreprocessorDefinitions Condition="'$(UseExperimentalWinUI3)'=='true'">USE_EXPERIMENTAL_WINUI3;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
    <!-- Enlighten IDL interfaces about WinUI3 -->
    <Midl>
      <PreprocessorDefinitions>USE_WINUI3;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <PreprocessorDefinitions Condition="'$(UseExperimentalWinUI3)'=='true'">USE_EXPERIMENTAL_WINUI3;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </Midl>
  </ItemDefinitionGroup>

  <ItemDefinitionGroup Condition="'$(DisableXamlGuard)'=='true'">
    <!-- Enlighten C++ code to not block WinUI2 and WinUI3 from loading in the same process. -->
    <ClCompile>
      <PreprocessorDefinitions>DISABLE_XAML_GUARD;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
  </ItemDefinitionGroup>

  <Target Name="PrintWinUIConfig" BeforeTargets="Midl;Build;ResolveSDKReferences">
    <Message Text="UseWinUI3 = $(UseWinUI3)" />
    <Message Text="WinUIPackage = $(WinUIPackageName).$(WinUIPackageVersion)" />
  </Target>
</Project>
