<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <Nullable>enable</Nullable>
    <BuiltInComInteropSupport>true</BuiltInComInteropSupport>
    <ApplicationManifest>app.manifest</ApplicationManifest>
    <AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
    <Platforms>x86;x64</Platforms>
    <AssemblyName>Plpext</AssemblyName>
    <SelfContained>true</SelfContained>
    <PublishReadyToRun>true</PublishReadyToRun>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
    <RuntimeIdentifier>win-x86</RuntimeIdentifier>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
  </PropertyGroup>



  <ItemGroup>
    <AvaloniaResource Include="Assets\**" />
    <AvaloniaResource Remove="ViewModels\Mocks\**" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Avalonia" Version="11.2.2" />
    <PackageReference Include="Avalonia.Controls.DataGrid" Version="11.2.2" />
    <PackageReference Include="Avalonia.Desktop" Version="11.2.2" />
    <PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.2" />
    <PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.2" />
    <!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
    <PackageReference Include="Avalonia.Diagnostics" Version="11.2.2">
      <IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
      <PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
    </PackageReference>
    <PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0-preview3" />
    <PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
    <PackageReference Include="Serilog" Version="4.1.0" />
    <PackageReference Include="Serilog.Extensions.Hosting" Version="8.0.0" />
    <PackageReference Include="Serilog.Sinks.Debug" Version="3.0.0" />
    <PackageReference Include="Velopack" Version="0.0.942" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\..\Plpext.Core\Plpext.Core.csproj" />
  </ItemGroup>

  <ItemGroup>
    <Compile Remove="ViewModels\Mocks\MockAudioPlayerViewModel.cs" />
    <Compile Remove="publish\**" />
    <Compile Remove="Releases\**" />
    <Compile Remove="ViewModels\Mocks\**" />
    <Compile Remove="ViewLocator.cs" />
  </ItemGroup>

  <ItemGroup>
    <AvaloniaXaml Remove="publish\**" />
    <AvaloniaXaml Remove="Releases\**" />
    <AvaloniaXaml Remove="ViewModels\Mocks\**" />
  </ItemGroup>

  <ItemGroup>
    <EmbeddedResource Remove="publish\**" />
    <EmbeddedResource Remove="Releases\**" />
    <EmbeddedResource Remove="ViewModels\Mocks\**" />
  </ItemGroup>

  <ItemGroup>
    <AdditionalFiles Remove="ViewModels\Mocks\**" />
  </ItemGroup>

  <ItemGroup>
    <None Remove="publish\**" />
    <None Remove="Releases\**" />
    <None Remove="ViewModels\Mocks\**" />
  </ItemGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
  <ItemGroup>
    <OpenAL32Dll_x86 Include="$(MSBuildProjectDirectory)\..\..\..\deps\win\x86\OpenAL32.dll" Condition="'$(RuntimeIdentifier)' == 'win-x86'" />
    <OpenAL32Dll_x64 Include="$(MSBuildProjectDirectory)\..\..\..\deps\win\x64\OpenAL32.dll" Condition="'$(RuntimeIdentifier)' == 'win-x64'" />
  </ItemGroup>
  <Copy SourceFiles="@(OpenAL32Dll_x86)" DestinationFiles="$(OutputPath)\OpenAL32_x86.dll" Condition="'$(RuntimeIdentifier)' == 'win-x86'" />
  <Copy SourceFiles="@(OpenAL32Dll_x64)" DestinationFiles="$(OutputPath)\OpenAL32_x64.dll" Condition="'$(RuntimeIdentifier)' == 'win-x64'" />
</Target>

<Target Name="PublishOpenAL" AfterTargets="Publish">
  <ItemGroup>
    <OpenAL32Dll Include="$(MSBuildProjectDirectory)\..\..\..\deps\win\x64\OpenAL32.dll" Condition="'$(RuntimeIdentifier)' == 'win-x64'" />
  </ItemGroup>
  <Copy SourceFiles="@(OpenAL32Dll)" DestinationFiles="$(PublishDir)\OpenAL32.dll" />
</Target>
</Project>
