<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <RuntimeIdentifiers>win-x64;osx-x64;linux-x64;win-arm64;osx-arm64;linux-arm64;</RuntimeIdentifiers>
    <OutputType>Exe</OutputType>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
    <Version>1.0.0-dirty</Version>
    <DefineConstants Condition=" '$(ExtraDefineConstants)' != '' ">$(DefineConstants);$(ExtraDefineConstants)</DefineConstants>
    <SigningCertificate Condition=" '$(SigningCertificate)' == '' ">-</SigningCertificate>
    <ApplicationIcon>Ryujinx.ico</ApplicationIcon>
    <TieredPGO>true</TieredPGO>
    <AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
    <ApplicationManifest>app.manifest</ApplicationManifest>
    <DefaultItemExcludes>$(DefaultItemExcludes);._*</DefaultItemExcludes>
  </PropertyGroup>

  <Target Name="BuildValidationProj" BeforeTargets="BeforeRebuild">
    <MSBuild Projects="..\Ryujinx.BuildValidationTasks\Ryujinx.BuildValidationTasks.csproj" Targets="Rebuild">
    </MSBuild>
  </Target>

  <Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="$([MSBuild]::IsOSPlatform('OSX'))">
    <Exec Command="codesign --entitlements '$(ProjectDir)..\..\distribution\macos\entitlements.xml' -f -s $(SigningCertificate) '$(TargetDir)$(TargetName)'" />
  </Target>

  <PropertyGroup Condition="'$(RuntimeIdentifier)' != ''">
    <PublishSingleFile>true</PublishSingleFile>
    <TrimmerSingleWarn>false</TrimmerSingleWarn>
    <PublishTrimmed>true</PublishTrimmed>
    <TrimMode>partial</TrimMode>
  </PropertyGroup>

  <PropertyGroup Condition="'$(RuntimeIdentifier)' == 'win-arm64'">
    <PublishSingleFile>true</PublishSingleFile>
    <PublishTrimmed>false</PublishTrimmed>
  </PropertyGroup>
  
  <!--
    FluentAvalonia, used in the Avalonia UI, requires a workaround for the json serializer used internally when using .NET 8+ System.Text.Json.
    See:
      https://github.com/amwx/FluentAvalonia/issues/481
      https://devblogs.microsoft.com/dotnet/system-text-json-in-dotnet-8/
  -->
  
  <PropertyGroup>
    <JsonSerializerIsReflectionEnabledByDefault>true</JsonSerializerIsReflectionEnabledByDefault>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Avalonia" />
    <PackageReference Include="Avalonia.Desktop" />
    <PackageReference Include="Avalonia.Diagnostics" Condition="'$(Configuration)'=='Debug'" />
    <PackageReference Include="Avalonia.Controls.DataGrid" />
    <PackageReference Include="Avalonia.Markup.Xaml.Loader" />
    <PackageReference Include="Svg.Controls.Avalonia" />
    <PackageReference Include="Svg.Controls.Skia.Avalonia" />
    <PackageReference Include="DynamicData" />
    <PackageReference Include="FluentAvaloniaUI.NoAnim" />
    <PackageReference Include="CommandLineParser" />
    <PackageReference Include="CommunityToolkit.Mvvm" />
    <PackageReference Include="DiscordRichPresence" />
    <PackageReference Include="Projektanker.Icons.Avalonia" />
    <PackageReference Include="Projektanker.Icons.Avalonia.FontAwesome" />
    <PackageReference Include="Projektanker.Icons.Avalonia.MaterialDesign" />
    <PackageReference Include="OpenTK.Core" />
    <PackageReference Include="Ryujinx.Audio.OpenAL.Dependencies" Condition="'$(RuntimeIdentifier)' != 'linux-x64' AND '$(RuntimeIdentifier)' != 'linux-arm64' AND '$(RuntimeIdentifier)' != 'osx-x64' AND '$(RuntimeIdentifier)' != 'osx-arm64'" />
    <PackageReference Include="Ryujinx.Graphics.Nvdec.Dependencies.AllArch" />
    <PackageReference Include="Ryujinx.Graphics.Vulkan.Dependencies.MoltenVK" Condition="'$(RuntimeIdentifier)' != 'linux-x64' AND '$(RuntimeIdentifier)' != 'linux-arm64' AND '$(RuntimeIdentifier)' != 'win-x64' AND '$(RuntimeIdentifier)' != 'win-arm64'" />
    <PackageReference Include="Ryujinx.UpdateClient" />
    <PackageReference Include="Ryujinx.Systems.Update.Common" />
    <PackageReference Include="securifybv.ShellLink" />
    <PackageReference Include="Sep" />
    <PackageReference Include="Silk.NET.Vulkan" />
    <PackageReference Include="Silk.NET.Vulkan.Extensions.EXT" />
    <PackageReference Include="Silk.NET.Vulkan.Extensions.KHR" />
    <PackageReference Include="SPB" />
    <PackageReference Include="SharpZipLib" />
  </ItemGroup>
  
  <ItemGroup>
    <ProjectReference Include="..\Ryujinx.Audio.Backends.SDL3\Ryujinx.Audio.Backends.SDL3.csproj" />
    <ProjectReference Include="..\Ryujinx.Graphics.RenderDocApi\Ryujinx.Graphics.RenderDocApi.csproj" />
    <ProjectReference Include="..\Ryujinx.Graphics.Vulkan/Ryujinx.Graphics.Vulkan.csproj" />
    <ProjectReference Include="..\Ryujinx.Graphics.OpenGL/Ryujinx.Graphics.OpenGL.csproj" />
    <ProjectReference Include="..\Ryujinx.Input\Ryujinx.Input.csproj" />
    <ProjectReference Include="..\Ryujinx.Input.SDL3\Ryujinx.Input.SDL3.csproj" />
    <ProjectReference Include="..\Ryujinx.Audio.Backends.OpenAL\Ryujinx.Audio.Backends.OpenAL.csproj" />
    <ProjectReference Include="..\Ryujinx.Audio.Backends.SoundIo\Ryujinx.Audio.Backends.SoundIo.csproj" />
    <ProjectReference Include="..\Ryujinx.Common\Ryujinx.Common.csproj" />
    <ProjectReference Include="..\Ryujinx.HLE\Ryujinx.HLE.csproj" />
    <ProjectReference Include="..\ARMeilleure\ARMeilleure.csproj" />
    <ProjectReference Include="..\Ryujinx.Graphics.Gpu\Ryujinx.Graphics.Gpu.csproj" />
    <ProjectReference Include="..\Ryujinx.UI.LocaleGenerator\Ryujinx.UI.LocaleGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
  </ItemGroup>

  <ItemGroup>
    <Content Include="..\..\distribution\windows\alsoft.ini" Condition="'$(RuntimeIdentifier)' != 'linux-x64' AND '$(RuntimeIdentifier)' != 'linux-arm64' AND '$(RuntimeIdentifier)' != 'osx-x64' AND '$(RuntimeIdentifier)' != 'osx-arm64'">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
      <TargetPath>alsoft.ini</TargetPath>
    </Content>
    <Content Include="..\..\distribution\legal\THIRDPARTY.md">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
      <TargetPath>THIRDPARTY.md</TargetPath>
      <Visible>False</Visible>
    </Content>
    <Content Include="..\..\LICENSE.txt">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
      <TargetPath>LICENSE.txt</TargetPath>
      <Visible>False</Visible>
    </Content>
  </ItemGroup>

  <ItemGroup Condition="'$(RuntimeIdentifier)' == 'linux-x64' OR '$(RuntimeIdentifier)' == 'linux-arm64' OR ('$(RuntimeIdentifier)' == '' AND $([MSBuild]::IsOSPlatform('Linux')))">
    <Content Include="..\..\distribution\linux\Ryujinx.sh">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <Content Include="..\..\distribution\linux\mime\Ryujinx.xml">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
      <TargetPath>mime\Ryujinx.xml</TargetPath>
    </Content>
  </ItemGroup>

  <ItemGroup>
    <AvaloniaResource Include="UI\**\*.xaml">
      <SubType>Designer</SubType>
    </AvaloniaResource>
    <AvaloniaResource Include="Assets\Fonts\Mono\JetBrainsMonoNL-Bold.ttf" />
    <AvaloniaResource Include="Assets\Fonts\Mono\JetBrainsMonoNL-BoldItalic.ttf" />
    <AvaloniaResource Include="Assets\Fonts\Mono\JetBrainsMonoNL-Italic.ttf" />
    <AvaloniaResource Include="Assets\Fonts\Mono\JetBrainsMonoNL-Regular.ttf" />
    <AvaloniaResource Include="Assets\Fonts\SegoeFluentIcons.ttf" />
    <AvaloniaResource Include="Assets\Styles\Themes.xaml">
      <Generator>MSBuild:Compile</Generator>
    </AvaloniaResource>
    <AvaloniaResource Include="Assets\Styles\Styles.xaml" />
  </ItemGroup>

  <ItemGroup>
    <None Remove="Assets\**\*.json" />
    <None Remove="Assets\Styles\Styles.xaml" />
    <None Remove="Assets\Styles\Themes.xaml" />
    <None Remove="Assets\Icons\Controller_JoyConLeft.svg" />
    <None Remove="Assets\Icons\Controller_JoyConPair.svg" />
    <None Remove="Assets\Icons\Controller_JoyConRight.svg" />
    <None Remove="Assets\Icons\Controller_ProCon.svg" />
  </ItemGroup>

  <ItemGroup>
    <EmbeddedResource Include="..\..\distribution\linux\shortcut-template.desktop">
      <Link>Assets\ShortcutFiles\shortcut-template.desktop</Link>
    </EmbeddedResource>
    <EmbeddedResource Include="..\..\distribution\macos\shortcut-launch-script.sh">
      <Link>Assets\ShortcutFiles\shortcut-launch-script.sh</Link>
    </EmbeddedResource>
    <EmbeddedResource Include="..\..\distribution\macos\shortcut-template.plist">
      <Link>Assets\ShortcutFiles\shortcut-template.plist</Link>
    </EmbeddedResource>
    <EmbeddedResource Include="..\..\docs\compatibility.csv" LogicalName="RyujinxGameCompatibilityList">
      <Link>Assets\RyujinxGameCompatibility.csv</Link>
    </EmbeddedResource>
    <EmbeddedResource Include="..\..\assets\**\*.json">
      <LinkBase>Assets</LinkBase>
    </EmbeddedResource>
    <EmbeddedResource Include="Assets\Styles\Styles.xaml" />
    <EmbeddedResource Include="Assets\Icons\Controller_JoyConLeft.svg" />
    <EmbeddedResource Include="Assets\Icons\Controller_JoyConPair.svg" />
    <EmbeddedResource Include="Assets\Icons\Controller_JoyConRight.svg" />
    <EmbeddedResource Include="Assets\Icons\Controller_ProCon.svg" />
    <EmbeddedResource Include="Assets\UIImages\Icon_NCA.png" />
    <EmbeddedResource Include="Assets\UIImages\Icon_NRO.png" />
    <EmbeddedResource Include="Assets\UIImages\Icon_NSO.png" />
    <EmbeddedResource Include="Assets\UIImages\Icon_NSP.png" />
    <EmbeddedResource Include="Assets\UIImages\Icon_XCI.png" />
    <EmbeddedResource Include="Assets\UIImages\Logo_Amiibo.png" />
    <EmbeddedResource Include="Assets\UIImages\Logo_Discord_Dark.png" />
    <EmbeddedResource Include="Assets\UIImages\Logo_Discord_Light.png" />
    <EmbeddedResource Include="Assets\UIImages\Logo_GitLab_Dark.png" />
    <EmbeddedResource Include="Assets\UIImages\Logo_GitLab_Light.png" />
    <EmbeddedResource Include="Assets\UIImages\Logo_Ryujinx.png" />
    <EmbeddedResource Include="Assets\UIImages\Logo_Ryujinx_AntiAlias.png" />
  </ItemGroup>
  <ItemGroup>
    <AdditionalFiles Include="..\..\assets\Locales\*.json" />
  </ItemGroup>
</Project>
