<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <Version>0.5.0</Version>
    <Copyright>Copyright © Nicolas Gnyra 2019-2023</Copyright>
  </PropertyGroup>

  <ItemGroup>
    <None Include="DynamicOpenVR.UntilYouFall.csproj.user" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="4.5.0">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\DynamicOpenVR.IL2CPP\DynamicOpenVR.IL2CPP.csproj" />
  </ItemGroup>

  <ItemGroup>
    <Reference Include="BepInEx.Core">
      <HintPath>$(GameDir)\BepInEx\core\BepInEx.Core.dll</HintPath>
      <Private>false</Private>
    </Reference>
    <Reference Include="BepInEx.IL2CPP">
      <HintPath>$(GameDir)\BepInEx\core\BepInEx.Unity.IL2CPP.dll</HintPath>
      <Private>false</Private>
    </Reference>
    <Reference Include="UnhollowerBaseLib">
      <HintPath>$(GameDir)\BepInEx\core\Il2CppInterop.Common.dll</HintPath>
      <Private>false</Private>
    </Reference>
    <Reference Include="UnhollowerBaseLib">
      <HintPath>$(GameDir)\BepInEx\core\Il2CppInterop.Runtime.dll</HintPath>
      <Private>false</Private>
    </Reference>
    <Reference Include="Il2Cppmscorlib">
      <HintPath>$(GameDir)\BepInEx\interop\Il2Cppmscorlib.dll</HintPath>
      <Private>false</Private>
    </Reference>
    <Reference Include="UnityEngine">
      <HintPath>$(GameDir)\BepInEx\interop\UnityEngine.dll</HintPath>
      <Private>false</Private>
    </Reference>
    <Reference Include="UnityEngine.CoreModule">
      <HintPath>$(GameDir)\BepInEx\interop\UnityEngine.CoreModule.dll</HintPath>
      <Private>false</Private>
    </Reference>
    <Reference Include="UnityEngine.XRModule">
      <HintPath>$(GameDir)\BepInEx\interop\UnityEngine.XRModule.dll</HintPath>
      <Private>false</Private>
    </Reference>
    <Reference Include="UnityEngine.VRModule">
      <HintPath>$(GameDir)\BepInEx\interop\UnityEngine.VRModule.dll</HintPath>
      <Private>false</Private>
    </Reference>
  </ItemGroup>

  <Target Name="PublishForBepInEx" AfterTargets="Publish">
    <!-- clean up -->
    <RemoveDir Directories="$(PublishDir)" />
    
    <!-- create Plugins folder and move plugin DLL/PDB inside -->
    <MakeDir Directories="$(PublishDir)" />

    <Copy SourceFiles="$(TargetPath)" DestinationFolder="$(PublishDir)BepInEx\plugins" />
    <Copy SourceFiles="$(TargetDir)$(TargetName).pdb" DestinationFolder="$(PublishDir)BepInEx\plugins" Condition="Exists('$(TargetDir)$(TargetName).pdb')" />
  </Target>

  <Target Name="CopyToGameDir" AfterTargets="AfterBuild" Condition="$(GameDir) != ''">
    <Copy SourceFiles="$(TargetDir)DynamicOpenVR.IL2CPP.dll" DestinationFolder="$(GameDir)\BepInEx\plugins" />
    <Copy SourceFiles="$(TargetDir)DynamicOpenVR.IL2CPP.xml" DestinationFolder="$(GameDir)\BepInEx\plugins" />
    <Copy SourceFiles="$(TargetDir)DynamicOpenVR.IL2CPP.pdb" DestinationFolder="$(GameDir)\BepInEx\plugins" Condition="Exists('$(TargetDir)DynamicOpenVR.IL2CPP.pdb')" />

    <Copy SourceFiles="$(TargetPath)" DestinationFolder="$(GameDir)\BepInEx\plugins" />
    <Copy SourceFiles="$(TargetDir)$(TargetName).pdb" DestinationFolder="$(GameDir)\BepInEx\plugins" Condition="Exists('$(TargetDir)$(TargetName).pdb')" />
  </Target>
</Project>
