<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 <!-- <Target Name="GenerateLayouts" AfterTargets="Build" Inputs="bin\Debug\$(TargetFramework)\PixiEditor.Extensions.Wasm.dll" Outputs="$(RootFolder)\Layouts\">
    <Exec  ConsoleToMSBuild="true"
          Command="..\PixiEditor.Extensions.MSBuildLayoutCompiler\bin\Debug\net8.0\PixiEditor.Extensions.MSBuildLayoutCompiler.exe $(OutputPath)\$(MSBuildProjectName).dll $(OutputPath)\Layouts\"/>
  </Target>-->

  <UsingTask TaskName="GenerateCGlueTask"
             AssemblyFile="$(MSBuildThisFileDirectory)PixiEditor.Api.CGlueMSBuild.dll" Condition="'$(RuntimeIdentifier)' == 'wasi-wasm'"/>
  <Target Name="GenerateGlueCode" AfterTargets="Build" BeforeTargets="_BeforeWasmBuildApp" Condition="'$(RuntimeIdentifier)' == 'wasi-wasm'">
    <GenerateCGlueTask AssemblyPath="$(TargetPath)" OutputPath="$(IntermediateOutputPath)native" InteropCFilePath="$(MSBuildThisFileDirectory)..\native\interop.c" />
    <ItemGroup>
      <NativeFileReference Include="$(IntermediateOutputPath)native\*.c" />
      <_WasmNativeFileForLinking Include="@(NativeFileReference)" />
    </ItemGroup>
  </Target>
  <UsingTask TaskName="BuildPackageTask"
             AssemblyFile="$(MSBuildThisFileDirectory)PixiEditor.Extensions.MSPackageBuilder.dll"
             Condition="'$(RuntimeIdentifier)' == 'wasi-wasm' And '$(GenerateExtensionPackage)' == 'true'"/>

  <Target Name="BuildPackageTask" AfterTargets="_WasiGenerateAppBundle" Condition="'$(RuntimeIdentifier)' == 'wasi-wasm' And '$(GenerateExtensionPackage)' == 'true'">
    <Message Text="Building extension package"/>
    <PropertyGroup Condition="'$(PixiExtOutputPath)' == ''">
      <PixiExtOutputPath>$(OutputPath)PixiExtension</PixiExtOutputPath>
    </PropertyGroup>
    <BuildPackageTask BuildResultDirectory="$(OutputPath)" TargetDirectory="$(PixiExtOutputPath)" />
  </Target>
</Project>