<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <PublishSingleFile>true</PublishSingleFile>
    <SelfContained>true</SelfContained>
    <IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
    <EnableCompressionInSingleFile>true</EnableCompressionInSingleFile>
  </PropertyGroup>
  <PropertyGroup>
    <Version>1.0.0-beta.1</Version>
    <AssemblyVersion>1.0.0.0</AssemblyVersion>
    <FileVersion>1.0.0.0</FileVersion>
    <InformationalVersion>1.0.0-beta.1</InformationalVersion>
    <Copyright>© $([System.DateTime]::Now.Year) Natalia Portillo</Copyright>
    <ApplicationIcon>Assets/romrepomgr.ico</ApplicationIcon>
  </PropertyGroup>
  <ItemGroup>
    <Compile Update="**\*.xaml.cs">
      <DependentUpon>%(Filename)</DependentUpon>
    </Compile>
    <None Remove="**\*.xaml"/>
    <AvaloniaResource Include="**\*.xaml">
      <SubType>Designer</SubType>
    </AvaloniaResource>
  </ItemGroup>
  <ItemGroup>
    <AvaloniaResource Include="Assets\**"/>
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Avalonia"/>
    <PackageReference Include="Avalonia.Controls.DataGrid"/>
    <PackageReference Include="Avalonia.Desktop"/>
    <PackageReference Include="Avalonia.Diagnostics"/>
    <PackageReference Include="Avalonia.Svg.Skia"/>
    <PackageReference Include="Avalonia.Themes.Fluent"/>
    <PackageReference Include="CommunityToolkit.Mvvm"/>
    <PackageReference Include="MessageBox.Avalonia"/>
    <PackageReference Include="AsyncFixer"/>
    <PackageReference Include="ErrorProne.NET.CoreAnalyzers"/>
    <PackageReference Include="ErrorProne.NET.Structs"/>
    <PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers"/>
    <PackageReference Include="Philips.CodeAnalysis.MaintainabilityAnalyzers"/>
    <PackageReference Include="Roslynator.Analyzers"/>
    <PackageReference Include="Roslynator.CodeAnalysis.Analyzers"/>
    <PackageReference Include="Roslynator.Formatting.Analyzers"/>
    <PackageReference Include="Serilog"/>
    <PackageReference Include="Serilog.Extensions.Logging"/>
    <PackageReference Include="Serilog.Sinks.Console"/>
    <PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer"/>
    <PackageReference Include="Text.Analyzers"/>
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\RomRepoMgr.Database\RomRepoMgr.Database.csproj"/>
    <ProjectReference Include="..\RomRepoMgr.Settings\RomRepoMgr.Settings.csproj"/>
    <ProjectReference Include="..\RomRepoMgr.Core\RomRepoMgr.Core.csproj"/>
  </ItemGroup>
  <ItemGroup>
    <EmbeddedResource Update="Resources\Localization.resx">
      <Generator>PublicResXFileCodeGenerator</Generator>
      <LastGenOutput>Localization.Designer.cs</LastGenOutput>
    </EmbeddedResource>
  </ItemGroup>

  <Target Name="CreateMacAppBundle" AfterTargets="Publish" Condition="'$(RuntimeIdentifier)' == 'osx-x64' Or '$(RuntimeIdentifier)' == 'osx-arm64'">
    <!-- Create Directory Structure -->
    <MakeDir Directories="
    $(PublishDir)MacPackage/RomRepoMgr.app/Contents/MacOS;
    $(PublishDir)MacPackage/RomRepoMgr.app/Contents/Resources" />

    <!-- Copy Executable -->
    <Copy SourceFiles="$(PublishDir)RomRepoMgr" DestinationFiles="$(PublishDir)MacPackage/RomRepoMgr.app/Contents/MacOS/RomRepoMgr" />

    <!-- Copy .dylib files -->
    <ItemGroup>
      <DylibFiles Include="$(PublishDir)**\*.dylib" />
    </ItemGroup>
    <Copy SourceFiles="@(DylibFiles)" DestinationFolder="$(PublishDir)MacPackage/RomRepoMgr.app/Contents/MacOS\%(RecursiveDir)" />

    <!-- Copy Icon (optional) -->
    <Copy SourceFiles="Assets/RomRepoMgr.icns" DestinationFiles="$(PublishDir)MacPackage/RomRepoMgr.app/Contents/Resources/RomRepoMgr.icns" />

    <!-- Generate Info.plist -->
    <WriteLinesToFile File="$(PublishDir)MacPackage/RomRepoMgr.app/Contents/Info.plist" Lines="
    &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
    &lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;
    &lt;plist version=&quot;1.0&quot;&gt;
    &lt;dict&gt;
      &lt;key&gt;CFBundleName&lt;/key&gt;&lt;string&gt;RomRepoMgr&lt;/string&gt;
      &lt;key&gt;CFBundleIdentifier&lt;/key&gt;&lt;string&gt;es.natportillo.romrepomgr&lt;/string&gt;
      &lt;key&gt;CFBundleVersion&lt;/key&gt;&lt;string&gt;1.0&lt;/string&gt;
      &lt;key&gt;CFBundleExecutable&lt;/key&gt;&lt;string&gt;RomRepoMgr&lt;/string&gt;
      &lt;key&gt;CFBundleIconFile&lt;/key&gt;&lt;string&gt;RomRepoMgr.icns&lt;/string&gt;
      &lt;key&gt;NSHumanReadableCopyright&lt;/key&gt;&lt;string&gt;© 2025 Nat Portillo.&lt;/string&gt;
    &lt;/dict&gt;
    &lt;/plist&gt;" Overwrite="true" />
  </Target>

</Project>
