<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

    <Import Project="Nitrox.Shared.props" />

    <!-- Framework properties -->
    <PropertyGroup>
        <LangVersion>13</LangVersion>
        <Version>1.8.0.0</Version>
        <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
        <Prefer32Bit>false</Prefer32Bit>
        <DebugType>embedded</DebugType>
        <Nullable>annotations</Nullable>
        <ImplicitUsings>disable</ImplicitUsings>
        <PathMap>$(MSBuildProjectDirectory)=$(MSBuildProjectName)</PathMap>
        <EnableNETAnalyzers>true</EnableNETAnalyzers>
        <AccelerateBuildsInVisualStudio>false</AccelerateBuildsInVisualStudio>
        <DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
    </PropertyGroup>

    <!-- Nitrox specific properties -->
    <PropertyGroup>
        <!-- Fix for dotnet build CLI ; MSBuildThisFileDirectory refers to the folder where Directory.Build.props is defined -->
        <NitroxRootDir>$(MSBuildThisFileDirectory)</NitroxRootDir>
        <Authors>Nitrox</Authors>
        <Company>Nitrox</Company>
        <NitroxProject>false</NitroxProject>
        <TestLibrary>false</TestLibrary>
        <NitroxLibrary>false</NitroxLibrary>
        <UnityModLibrary>false</UnityModLibrary>
    </PropertyGroup>

    <PropertyGroup Condition="$([System.Text.RegularExpressions.Regex]::IsMatch($(MSBuildProjectName), '^Nitrox.*$'))">
        <NitroxProject>true</NitroxProject>
    </PropertyGroup>
    <PropertyGroup Condition="'$(NitroxProject)' == 'true' and '$(MSBuildProjectName)' != 'Nitrox.Test'">
        <NitroxLibrary>true</NitroxLibrary>
    </PropertyGroup>
    <PropertyGroup Condition="'$(NitroxLibrary)' == 'true' and '$(MSBuildProjectName)' != 'NitroxModel' and '$(MSBuildProjectName)' != 'NitroxServer' and '$(MSBuildProjectName)' != 'Nitrox.Launcher'">
        <UnityModLibrary>true</UnityModLibrary>
    </PropertyGroup>
    <PropertyGroup Condition="'$(MSBuildProjectName)' == 'Nitrox.Test'">
        <TestLibrary>true</TestLibrary>
    </PropertyGroup>
    <PropertyGroup>
        <NotTestLibrary>false</NotTestLibrary>
        <NotTestLibrary Condition="'$(TestLibrary)' == 'false'">true</NotTestLibrary>
    </PropertyGroup>

    <!-- Shared dependencies for all Nitrox.* projects -->
    <ItemGroup Condition="'$(NitroxProject)' == 'true'">
        <PackageReference Include="JetBrains.Annotations" Version="2024.3.0">
            <Aliases>JB</Aliases>
        </PackageReference>
        <PackageReference Include="IsExternalInit" Version="1.0.3">
            <PrivateAssets>all</PrivateAssets>
            <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
        </PackageReference>
        <PackageReference Include="IndexRange" Version="1.0.3" />
        <PackageReference Include="System.Memory" Version="4.6.3" />
        <PackageReference Include="System.ValueTuple" Version="4.6.1" />
    </ItemGroup>

    <Choose>
        <When Condition="'$(TestLibrary)' == 'false'">
            <ItemGroup>
                <PackageReference Include="Nitrox.Analyzers" Version="*">
                    <PrivateAssets>all</PrivateAssets>
                    <IncludeAssets>build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
                </PackageReference>
            </ItemGroup>
        </When>
    </Choose>

    <!-- Include default project references to all other "Nitrox*" projects -->
    <Choose>
        <When Condition="'$(UnityModLibrary)' == 'true' or '$(TestLibrary)' == 'true'">
            <ItemGroup>
                <PackageReference Include="BepInEx.AssemblyPublicizer.MSBuild" Version="0.4.2">
                    <PrivateAssets>all</PrivateAssets>
                    <IncludeAssets>build; native; contentfiles; analyzers</IncludeAssets>
                </PackageReference>
                <PackageReference Include="Nitrox.Discovery.MSBuild" Version="0.1.0">
                    <PrivateAssets>all</PrivateAssets>
                    <IncludeAssets>build; native; contentfiles; analyzers</IncludeAssets>
                </PackageReference>
            </ItemGroup>
        </When>
    </Choose>

    <!-- Set internals visible for all projects for Nitrox.Test (excluding Nitrox.Test itself) -->
    <Choose>
        <When Condition="'$(NitroxLibrary)' == 'true'">
            <ItemGroup>
                <AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
                    <_Parameter1>Nitrox.Test</_Parameter1>
                </AssemblyAttribute>
            </ItemGroup>
        </When>
    </Choose>
</Project>
