<Project Sdk="Microsoft.NET.Sdk">
    <!--
      Use an OS-specific TargetFramework to make use of platform-specific APIs on Windows and macOS.
      Otherwise, fall back to net10.0 for Linux and other platforms.
    -->
    <Import Project="Host.props" />
    <PropertyGroup Condition="'$(_HostIsWindows)'=='true' And '$(IsAndroid)'!='true'">
        <TargetFramework>net10.0-windows10.0.19041</TargetFramework>
    </PropertyGroup>
    <PropertyGroup Condition="'$(_HostIsOSX)'=='true' And '$(IsAndroid)'!='true'">
        <TargetFramework>net10.0-macos</TargetFramework>
    </PropertyGroup>
    <PropertyGroup Condition="'$(TargetFramework)'==''">
        <TargetFramework>net10.0</TargetFramework>
    </PropertyGroup>

    <!-- Detect target platform -->
    <Import Project="Platform.props" />
    <PropertyGroup Condition="'$(IsWindows)'=='true'">
        <OutputType>WinExe</OutputType>

        <!-- Causes crashes on Windows 10/11 if not fully updated: https://github.com/dotnet/runtime/issues/121596 -->
        <CetCompat>false</CetCompat>
    </PropertyGroup>
    <PropertyGroup Condition="'$(IsOSX)'=='true'">
        <OutputType>Exe</OutputType>

        <RuntimeIdentifiers>osx-x64;osx-arm64</RuntimeIdentifiers>
        <_XSAppIconAssets>Assets.xcassets/AppIcon.appiconset</_XSAppIconAssets>
        <AssemblyName>Galaxy Buds Manager</AssemblyName>
        <SupportedOSPlatformVersion>12.0</SupportedOSPlatformVersion>
    </PropertyGroup>
    <PropertyGroup Condition="'$(IsLinux)'=='true'">
        <OutputType>Exe</OutputType>
    </PropertyGroup>
    <PropertyGroup Condition="'$(IsAndroid)'=='true'">
        <OutputType>Library</OutputType>
        <DefineConstants>$(DefineConstants);Android</DefineConstants>
    </PropertyGroup>
    
    <Import Project="Application.props" />
    
    <PropertyGroup>
        <!-- App properties -->
        <ApplicationIcon>Resources\icon.ico</ApplicationIcon>
        <ApplicationManifest>app.manifest</ApplicationManifest>
        
        <!-- Build properties -->
        <Nullable>enable</Nullable>
        <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
        <EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
        <AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
        <DisableWinExeOutputInference>false</DisableWinExeOutputInference>
        <IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
        <LangVersion>latest</LangVersion>
        
        <!-- Code Analysis -->
        <AnalysisLevel>latest</AnalysisLevel>
        <EnableNETAnalyzers>true</EnableNETAnalyzers>
        
        <!-- Build configurations -->
        <Configurations>Debug;Release</Configurations>
        <Platforms>AnyCPU</Platforms>
    </PropertyGroup>

    <!-- Android: we set the package name in GalaxyBudsClient.Android -->
    <PropertyGroup Condition="'$(IsAndroid)'!='true'">
        <ApplicationId>me.timschneeberger.galaxybudsclient</ApplicationId>
    </PropertyGroup>
    
    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
        <DebugSymbols>true</DebugSymbols>
    </PropertyGroup>
    
    <!-- Resources -->
    <ItemGroup>
        <AvaloniaResource Include="Resources\**" />
        
        <Compile Update="**\*.axaml.cs">
            <DependentUpon>%(Filename)</DependentUpon>
            <SubType>Code</SubType>
        </Compile>

        <Compile Remove="bin\**" />
        <AvaloniaResource Remove="bin\**" />
        <AvaloniaXaml Remove="bin\**" />
        <EmbeddedResource Remove="bin\**" />
        <None Remove="bin\**" />
    </ItemGroup>
    
    <!-- Dependencies -->
    <ItemGroup>
        <PackageReference Include="AsyncErrorHandler.Fody" Version="1.3.0" />
        <PackageReference Include="Fody" Version="6.9.3" PrivateAssets="all" />
        <PackageReference Include="Avalonia" Version="$(AvaloniaVersion)" />
        <PackageReference Include="Avalonia.Controls.DataGrid" Version="$(AvaloniaVersion)" />
        <PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaVersion)" />
        <PackageReference Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)" />
        <PackageReference Include="Avalonia.Fonts.Inter" Version="$(AvaloniaVersion)" />
        <PackageReference Include="Avalonia.Markup.Xaml.Loader" Version="$(AvaloniaVersion)" />
        <PackageReference Include="Avalonia.Themes.Fluent" Version="$(AvaloniaVersion)" />
        <PackageReference Include="ReactiveUI.Avalonia" Version="11.3.8" />
        <PackageReference Include="Svg.Controls.Skia.Avalonia" Version="11.3.6.2" />
        <PackageReference Include="Xaml.Behaviors.Avalonia" Version="11.3.9" />
        <PackageReference Include="AvaloniaHex" Version="0.1.10" />
        <PackageReference Include="BouncyCastle.Cryptography" Version="2.6.2" />
        <PackageReference Include="CommandLineParser" Version="2.9.2-ci-210" />
        <PackageReference Include="Config.Net" Version="5.2.1" />
        <PackageReference Include="CS-Script" Version="4.13.0" />
        <PackageReference Include="FluentAvaloniaUI" Version="2.4.1" />
        <PackageReference Include="FluentIcons.Avalonia.Fluent" Version="2.0.316.1" />
        <PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="6.0.0" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.1">
            <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
            <PrivateAssets>all</PrivateAssets>
        </PackageReference>
        <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="10.0.3" />
        <PackageReference Include="ReactiveUI.Fody" Version="19.5.41" /> <!-- Needed due to workaround in SettingsData.cs -->
        <PackageReference Include="ReactiveUI.SourceGenerators" Version="2.5.1" PrivateAssets="all" />
        <PackageReference Include="ScottPlot.Avalonia" Version="5.1.57" />
        <PackageReference Include="Sentry" Version="6.0.0" />
        <PackageReference Include="Sentry.Serilog" Version="6.0.0" />
        <PackageReference Include="Serilog" Version="4.3.0" />
        <PackageReference Include="Serilog.Sinks.Console" Version="6.1.1" />
        <PackageReference Include="Serilog.Sinks.Debug" Version="3.0.0" />
        <PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
        <PackageReference Include="Serilog.Sinks.Trace" Version="4.0.0" />
        <!-- Workaround: force include SkiaSharp 3.x libraries for Linux; this is already implicitly the case for other platforms -->
        <PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="3.119.1" />
        <PackageReference Include="Tmds.DBus" Version="0.21.2" />
    </ItemGroup>


    <!-- Project references -->
    <ItemGroup Condition="'$(IsWindows)'=='true'">
        <ProjectReference Include="..\GalaxyBudsClient.Platform.WindowsRT\GalaxyBudsClient.Platform.WindowsRT.csproj" />
        <ProjectReference Include="..\GalaxyBudsClient.Platform.Windows\GalaxyBudsClient.Platform.Windows.csproj" />
    </ItemGroup>

    <ItemGroup Condition="'$(IsLinux)'=='true'">
        <ProjectReference Include="..\GalaxyBudsClient.Platform.Linux\GalaxyBudsClient.Platform.Linux.csproj" />
    </ItemGroup>
    
    <ItemGroup Condition="'$(IsOSX)'=='true'">
        <ProjectReference Include="..\GalaxyBudsClient.Platform.OSX\GalaxyBudsClient.Platform.OSX.csproj" />
    </ItemGroup>
    
    <ItemGroup>
        <ProjectReference Include="..\GalaxyBudsClient.Platform\GalaxyBudsClient.Platform.csproj" />

        <ProjectReference Include="..\GalaxyBudsClient.Generators\GalaxyBudsClient.Generators.csproj">
            <OutputItemType>Analyzer</OutputItemType>
            <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
        </ProjectReference>
    </ItemGroup>
</Project>
