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

    <PropertyGroup>
        <TargetFramework>net48</TargetFramework>
        <LangVersion>12</LangVersion>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
        <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
        <RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
        <EnableWindowsTargeting>true</EnableWindowsTargeting>
    </PropertyGroup>

    <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
        <DebugSymbols>false</DebugSymbols>
        <DebugType>none</DebugType>
    </PropertyGroup>

    <ItemGroup>
        <PackageReference Include="Krafs.Publicizer" Version="2.2.1">
          <PrivateAssets>all</PrivateAssets>
          <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
        </PackageReference>
        <PackageReference Include="PolySharp" Version="1.13.2">
          <PrivateAssets>all</PrivateAssets>
          <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
        </PackageReference>
        <PackageReference Include="torch.server.referenceassemblies" Version="1.3.1.260-master" PrivateAssets="all" IncludeAssets="compile" />
    </ItemGroup>
    
    <ItemGroup>
        <Publicize Include="Torch:Torch.TorchBase.RegisterAuxAssembly" />
        <Publicize Include="Torch:Torch.Managers.PluginManager._plugins" />
        <Publicize Include="Torch:Torch.TorchPluginBase.Manifest" />
        <Publicize Include="Torch:Torch.TorchPluginBase.StoragePath" />
    </ItemGroup>

    <ItemGroup>
        <Content Include="manifest.xml">
            <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
            <CopyToPublishDirectory>Always</CopyToPublishDirectory>
        </Content>
    </ItemGroup>

    <ItemGroup>
      <ProjectReference Include="..\LuckPerms.Torch\LuckPerms.Torch.csproj" ReferenceOutputAssembly="false" Private="false" />
    </ItemGroup>

    <ItemGroup>
      <Reference Include="System.IO.Compression" />
    </ItemGroup>
    
    <Target Name="BuildArchive" BeforeTargets="PreBuildEvent">
        <PropertyGroup>
            <PluginDir>..\LuckPerms.Torch\bin\$(Configuration)\$(TargetFramework)\win-x64\</PluginDir>
            <PluginZipPath>$(BaseIntermediateOutputPath)$(Configuration)\$(TargetFramework)\plugin.zip</PluginZipPath>
        </PropertyGroup>
        <ZipDirectory DestinationFile="$(PluginZipPath)" SourceDirectory="$(PluginDir)" Overwrite="true" />
        <ItemGroup>
            <EmbeddedResource Include="$(PluginZipPath)" LogicalName="plugin.zip" />
        </ItemGroup>
    </Target>

</Project>