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

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <Nullable>enable</Nullable>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="GirCore.Adw-1" Version="0.5.0-preview.3" />
    <PackageReference Include="Nickvision.Aura" Version="2023.11.4" />
    <PackageReference Include="HarfBuzzSharp.NativeAssets.Linux" Version="7.3.0" />
    <PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.88.6" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\NickvisionMoney.Shared\NickvisionMoney.Shared.csproj" />
  </ItemGroup>

  <Target Name="PreBuild" BeforeTargets="PreBuildEvent">
    <Exec Command="echo Compiling extra resources..." />
    <Exec Command="blueprint-compiler batch-compile ./Blueprints ./Blueprints ./Blueprints/*.blp" />
    <Exec Command="glib-compile-resources --sourcedir ./Resources ./Resources/org.nickvision.money.gresource.xml --target=$(OutDir)/org.nickvision.money.gresource" />
    <Exec Command="while read lang_code; do \&#xA;  mkdir -p $(OutDir)/${lang_code}; \&#xA;  msgfmt ../NickvisionMoney.Shared/Resources/po/${lang_code}.po -o $(OutDir)/${lang_code}/denaro.mo; \&#xA;done %3C ../NickvisionMoney.Shared/Resources/po/LINGUAS" />
  </Target>

  <Target Name="PostBuild" AfterTargets="PostBuildEvent">
    <Exec Command="rm ./Blueprints/*.ui" />
  </Target>

  <Target Name="PostPublish" AfterTargets="Publish">
    <Exec Command="cp $(OutDir)/org.nickvision.money.gresource $(PublishDir)/org.nickvision.money.gresource" />
    <Exec Command="while read lang_code; do \&#xA;  cp -r $(OutDir)/${lang_code} $(PublishDir)/; \&#xA;done %3C ../NickvisionMoney.Shared/Resources/po/LINGUAS" />
  </Target>

  <Target Name="EmbedUIFiles" BeforeTargets="BeforeResGen">
    <ItemGroup>
        <EmbeddedResource Include="Blueprints\*.ui" Type="Non-Resx" WithCulture="false" />
    </ItemGroup>
  </Target>

</Project>
