<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
        <OutputType>Exe</OutputType>
        <CheckEolTargetFramework>false</CheckEolTargetFramework>
        <IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
        <IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
        <LangVersion>latest</LangVersion>
        <Nullable>enable</Nullable>
        <SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
        <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
        <Version>2.0.0</Version>
    </PropertyGroup>

    <!-- Support All Frameworks -->
    <PropertyGroup Condition="$(TargetFramework.StartsWith(`net2`)) OR $(TargetFramework.StartsWith(`net3`)) OR $(TargetFramework.StartsWith(`net4`))">
        <RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers>
    </PropertyGroup>
    <PropertyGroup Condition="$(TargetFramework.StartsWith(`netcoreapp`)) OR $(TargetFramework.StartsWith(`net5`))">
        <RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64</RuntimeIdentifiers>
    </PropertyGroup>
    <PropertyGroup Condition="$(TargetFramework.StartsWith(`net6`)) OR $(TargetFramework.StartsWith(`net7`)) OR $(TargetFramework.StartsWith(`net8`)) OR $(TargetFramework.StartsWith(`net9`))">
        <RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
    </PropertyGroup>
    <PropertyGroup Condition="$(RuntimeIdentifier.StartsWith(`osx-arm`))">
        <TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
    </PropertyGroup>

    <!-- Set a build flag for Windows specifically -->
    <PropertyGroup Condition="'$(RuntimeIdentifier)'=='win-x86'">
        <DefineConstants>$(DefineConstants);WINX86</DefineConstants>
    </PropertyGroup>
    <PropertyGroup Condition="'$(RuntimeIdentifier)'=='win-x64'">
        <DefineConstants>$(DefineConstants);WINX64</DefineConstants>
    </PropertyGroup>

    <!-- These are needed for dealing with native Windows DLLs -->
    <ItemGroup Condition="'$(RuntimeIdentifier)'=='win-x86'">
        <ContentWithTargetPath Include="..\SabreTools.Serialization\runtimes\win-x86\native\CascLib.dll">
            <CopyToOutputDirectory>Always</CopyToOutputDirectory>
            <CopyToPublishDirectory>Always</CopyToPublishDirectory>
            <TargetPath>CascLib.dll</TargetPath>
        </ContentWithTargetPath>
        <ContentWithTargetPath Include="..\SabreTools.Serialization\runtimes\win-x86\native\StormLib.dll">
            <CopyToOutputDirectory>Always</CopyToOutputDirectory>
            <CopyToPublishDirectory>Always</CopyToPublishDirectory>
            <TargetPath>StormLib.dll</TargetPath>
        </ContentWithTargetPath>
    </ItemGroup>
    <ItemGroup Condition="'$(RuntimeIdentifier)'=='win-x64'">
        <ContentWithTargetPath Include="..\SabreTools.Serialization\runtimes\win-x64\native\CascLib.dll">
            <CopyToOutputDirectory>Always</CopyToOutputDirectory>
            <CopyToPublishDirectory>Always</CopyToPublishDirectory>
            <TargetPath>CascLib.dll</TargetPath>
        </ContentWithTargetPath>
        <ContentWithTargetPath Include="..\SabreTools.Serialization\runtimes\win-x64\native\StormLib.dll">
            <CopyToOutputDirectory>Always</CopyToOutputDirectory>
            <CopyToPublishDirectory>Always</CopyToPublishDirectory>
            <TargetPath>StormLib.dll</TargetPath>
        </ContentWithTargetPath>
    </ItemGroup>

    <ItemGroup>
        <ProjectReference Include="..\SabreTools.Serialization\SabreTools.Serialization.csproj" />
    </ItemGroup>

    <ItemGroup>
        <PackageReference Include="SabreTools.IO" Version="1.7.5" />
        <PackageReference Include="System.Text.Encoding.CodePages" Version="9.0.9" Condition="!$(TargetFramework.StartsWith(`net2`)) AND !$(TargetFramework.StartsWith(`net3`)) AND !$(TargetFramework.StartsWith(`net40`)) AND !$(TargetFramework.StartsWith(`net452`))" />
    </ItemGroup>

</Project>