<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <RootNamespace>DynamicOpenVR.BeatSaber</RootNamespace>
    <AssemblyName>DynamicOpenVR.BeatSaber</AssemblyName>
    <TargetFramework>net472</TargetFramework>
    <AutomatedBuild>false</AutomatedBuild>
    <PathMap>$(MSBuildProjectDirectory)=$(MSBuildProjectName)</PathMap>
    <SteamExecutable>C:\Program Files (x86)\Steam\steam.exe</SteamExecutable>
    <GenerateDocumentationFile>true</GenerateDocumentationFile>
    <LangVersion>10</LangVersion>
    <Version>0.5.0</Version>
    <Copyright>Copyright © Nicolas Gnyra 2019-2023</Copyright>
  </PropertyGroup>
  <PropertyGroup Condition="$(Configuration) == Release">
    <DebugType>none</DebugType>
    <DebugSymbols>false</DebugSymbols>
  </PropertyGroup>
  <ItemGroup>
    <None Include="DynamicOpenVR.BeatSaber.csproj.user" />
  </ItemGroup>
  <ItemGroup>
    <Reference Include="0Harmony">
      <HintPath>$(BeatSaberDir)\Libs\0Harmony.dll</HintPath>
    </Reference>
    <Reference Include="HMLib" Publicize="true">
      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\HMLib.dll</HintPath>
    </Reference>
    <Reference Include="HMUI">
      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\HMUI.dll</HintPath>
    </Reference>
    <Reference Include="IPA.Loader">
      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\IPA.Loader.dll</HintPath>
    </Reference>
    <Reference Include="Main">
      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\Main.dll</HintPath>
    </Reference>
    <Reference Include="MathUtils">
      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\MathUtils.dll</HintPath>
    </Reference>
    <Reference Include="Newtonsoft.Json">
      <HintPath>$(BeatSaberDir)\Libs\Newtonsoft.Json.dll</HintPath>
    </Reference>
    <Reference Include="Unity.TextMeshPro">
      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\Unity.TextMeshPro.dll</HintPath>
    </Reference>
    <Reference Include="UnityEngine">
      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.dll</HintPath>
    </Reference>
    <Reference Include="UnityEngine.CoreModule">
      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
    </Reference>
    <Reference Include="UnityEngine.InputLegacyModule">
      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.InputLegacyModule.dll</HintPath>
    </Reference>
    <Reference Include="Unity.XR.Management" Publicize="true">
      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\Unity.XR.Management.dll</HintPath>
    </Reference>
    <!-- since it isn't copied over before compilation, reference the local file -->
    <Reference Include="Unity.XR.OpenVR">
      <HintPath>..\..\Packaging\DynamicOpenVR.BeatSaber\Beat Saber_Data\Managed\Unity.XR.OpenVR.dll</HintPath>
    </Reference>
    <Reference Include="UnityEngine.UI">
      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.UI.dll</HintPath>
    </Reference>
    <Reference Include="UnityEngine.VRModule">
      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.VRModule.dll</HintPath>
    </Reference>
    <Reference Include="UnityEngine.XRModule">
      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.XRModule.dll</HintPath>
    </Reference>
    <Reference Include="Zenject">
      <HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\Zenject.dll</HintPath>
    </Reference>
  </ItemGroup>
  <ItemGroup>
    <EmbeddedResource Include="manifest.json" />
    <EmbeddedResource Include="Resources\icon.png" />
  </ItemGroup>
  <ItemGroup>
    <AdditionalFiles Include="stylecop.json" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\DynamicOpenVR\DynamicOpenVR.csproj" />
  </ItemGroup>
  <Target Name="PublishForBeatSaber" AfterTargets="Publish">
    <ItemGroup>
      <CopyToOutput Include="$(ProjectDir)..\..\Packaging\DynamicOpenVR.BeatSaber\**\*.*" />
    </ItemGroup>

    <!-- clean up -->
    <RemoveDir Directories="$(PublishDir)" />
    
    <!-- create Plugins folder and move plugin DLL/PDB inside -->
    <MakeDir Directories="$(PublishDir)Plugins" />
    <Copy SourceFiles="$(TargetPath)" DestinationFolder="$(PublishDir)Plugins" />
    <Copy SourceFiles="$(TargetDir)$(TargetName).pdb" DestinationFolder="$(PublishDir)Plugins" Condition="$(DebugType) != 'none'" />
    <Copy SourceFiles="$(TargetDir)$(TargetName).xml" DestinationFolder="$(PublishDir)Plugins" Condition="$(DebugType) != 'none'" />

    <!-- copy static files -->
    <Copy SourceFiles="@(CopyToOutput)" DestinationFiles="@(CopyToOutput->'$(PublishDir)\%(RecursiveDir)%(Filename)%(Extension)')" />
  </Target>
  <Target Name="CopyToBeatSaberFolder" AfterTargets="AfterBuild" Condition="$(BeatSaberDir) != ''">
    <ItemGroup>
      <CopyToBeatSaberFolder Include="$(ProjectDir)..\..\Packaging\DynamicOpenVR\**\*.*" />
      <CopyToBeatSaberFolder Include="$(ProjectDir)..\..\Packaging\DynamicOpenVR.BeatSaber\**\*.*" />
    </ItemGroup>

    <Copy SourceFiles="@(CopyToBeatSaberFolder)" DestinationFiles="@(CopyToBeatSaberFolder->'$(BeatSaberDir)\%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="$(TargetDir)DynamicOpenVR.dll" DestinationFolder="$(BeatSaberDir)\Libs" />
    <Copy SourceFiles="$(TargetDir)DynamicOpenVR.xml" DestinationFolder="$(BeatSaberDir)\Libs" />
    <Copy SourceFiles="$(TargetDir)DynamicOpenVR.pdb" DestinationFolder="$(BeatSaberDir)\Libs" Condition="Exists('$(TargetDir)DynamicOpenVR.pdb')" />
    <Copy SourceFiles="$(TargetPath)" DestinationFolder="$(BeatSaberDir)\Plugins" />
    <Copy SourceFiles="$(TargetDir)$(TargetName).xml" DestinationFolder="$(BeatSaberDir)\Plugins" />
    <Copy SourceFiles="$(TargetDir)$(TargetName).pdb" DestinationFolder="$(BeatSaberDir)\Plugins" Condition="Exists('$(TargetDir)$(TargetName).pdb')" />
  </Target>
  <ItemGroup>
    <PackageReference Include="BSIPA.AssemblyPublicizer.MSBuild" Version="0.5.0">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="IsExternalInit" Version="1.0.3">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="4.5.0">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.Unity.Analyzers" Version="1.17.0">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>
</Project>