<Project>
    <PropertyGroup>
        <IsHotReloadMainAssembly Condition="'$(OutputType)' == 'exe' OR '$(OutputType)' == 'winexe' OR '$(AndroidApplication)' == 'True' ">True</IsHotReloadMainAssembly>

        <!-- For iOS/Catalyst/tvOS, the interpreter must be enabled to use Hot Reload. -->
        <AppleWithInterpreterDisabled Condition="( $(TargetFramework.Contains('-ios')) OR $(TargetFramework.Contains('-catalyst')) OR $(TargetFramework.Contains('-tvos')) ) AND '$(MtouchInterpreter)' == '' AND '$(UseInterpreter)' != 'True'">True</AppleWithInterpreterDisabled>

        <!-- By default, Hot Reload is enabled for the Debug configuration for the main app assembly, but EnableHotReload can be set explicitly to override if desired for some reason. -->
        <EnableHotReload Condition="'$(EnableHotReload)' == '' AND '$(Configuration)' == 'Debug' AND '$(IsHotReloadMainAssembly)' == 'True' AND '$(AppleWithInterpreterDisabled)' != 'True'">True</EnableHotReload>
    </PropertyGroup>

    <Target Name="_HotReloadMessage" BeforeTargets="CoreCompile">
        <Message Importance="High" Text="Including assemblies for Hot Reload support" Condition="'$(EnableHotReload)' == 'True'" />
        <Message Importance="High" Text="Hot Reload disabled. Enable the interpreter in the project settings for debug builds to enable Hot Reload on iOS/Catalyst." Condition="'$(EnableHotReload)' != 'True' AND '$(AppleWithInterpreterDisabled)' == 'True' AND '$(Configuration)' == 'Debug'"/>
    </Target>

    <ItemGroup Condition="'$(EnableHotReload)' == 'True'">
        <Analyzer Include="$(MSBuildThisFileDirectory)Microsoft.VisualStudio.HotReload.MobileTapInitializer.dll"/>

        <Reference Include="$(MSBuildThisFileDirectory)Microsoft.Maui.Controls.HotReload.Forms.dll"/>
        <Reference Include="$(MSBuildThisFileDirectory)Microsoft.VisualStudio.DesignTools.MobileTapContracts.dll" />
        <Reference Include="$(MSBuildThisFileDirectory)Microsoft.VisualStudio.DesignTools.TapContract.dll"/>
        <Reference Include="$(MSBuildThisFileDirectory)Microsoft.VisualStudio.DesignTools.XamlTapContract.dll"/>
    </ItemGroup>
</Project>
