<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="PostBuild" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
  <PropertyGroup>
    <OPath></OPath>
    <SolDir></SolDir>
  </PropertyGroup>

  <UsingTask TaskName="AssemblyRename" AssemblyFile="$(SolDir)BuildTools\AssemblyRenameStep\bin\$(Configuration)\AssemblyRenameStep.dll" />
  
  <Target Name="PostBuild">
    <Message Text="Relocating" Importance="normal" />
    <ItemGroup>
      <SystemFiles Include="$(OPath)IPA.Injector.*" />
      <SystemFiles Include="$(OPath)IPA.Loader.*" />
      <SystemFiles Include="$(OPath)AsyncBridge.*" />
      <SystemFiles Include="$(OPath)System.*" />
      <SystemFiles Include="$(OPath)Portable.System.*" />
      <SystemFiles Include="$(OPath)Net3-Proxy.*" />
      <SystemFiles Include="$(OPath)Libraries\Mono\**\*" />
      <OldLibFiles Include="$(OPath)Libs\**\*" />
    </ItemGroup>
    <Move SourceFiles="@(SystemFiles)" DestinationFolder="$(OPath)Data\Managed" />
    <RemoveDir Directories="$(OPath)Libraries\Mono" />
    
    <Delete Files="@(OldLibFiles)" />
    <RemoveDir Directories="$(OPath)Libs" />
    <ItemGroup>
      <LibFiles Include="$(OPath)**\*" Exclude="$(OPath)Data\**\*;$(OPath)Libs\**\*" />
    </ItemGroup>
    <Move SourceFiles="@(LibFiles)" DestinationFolder="$(OPath)Libs\" />
    <RemoveDir Directories="$(OPath)Libraries\Included" />
    <RemoveDir Directories="$(OPath)Libraries" />
    
    <ItemGroup>
      <ToRename Include="$(OPath)Libs\**\*.dll" />
    </ItemGroup>
    <AssemblyRename Assemblies="@(ToRename)" />
  </Target>
</Project>