<Project>
  <!--
    StandardScene 插件工程编译后，自动将产物复制到 build\plugins\（SimpleComposer / SimpleLite 宿主加载目录）。
    适用：StandardScene.Core + Magnetic / QrLidar / Devices / Protocol.VDA5050 等卫星插件。
  -->
  <PropertyGroup>
    <StandardSceneRepoRoot>$(MSBuildThisFileDirectory)</StandardSceneRepoRoot>
    <StandardScenePluginsDir>$(StandardSceneRepoRoot)build\plugins</StandardScenePluginsDir>
    <IsStandardScenePluginCopy>false</IsStandardScenePluginCopy>
    <IsStandardScenePluginCopy Condition="'$(MSBuildProjectName)' == 'StandardScene.Core'">true</IsStandardScenePluginCopy>
    <IsStandardScenePluginCopy Condition="'$(MSBuildProjectName)' == 'StandardScene.Magnetic'">true</IsStandardScenePluginCopy>
    <IsStandardScenePluginCopy Condition="'$(MSBuildProjectName)' == 'StandardScene.QrLidar'">true</IsStandardScenePluginCopy>
    <IsStandardScenePluginCopy Condition="'$(MSBuildProjectName)' == 'StandardScene.Devices'">true</IsStandardScenePluginCopy>
    <IsStandardScenePluginCopy Condition="'$(MSBuildProjectName)' == 'StandardScene.Protocol.VDA5050'">true</IsStandardScenePluginCopy>
  </PropertyGroup>

  <Target Name="CopyStandardScenePluginOutputs"
          AfterTargets="Build"
          Condition="'$(IsStandardScenePluginCopy)' == 'true' and '$(TargetPath)' != ''">
    <MakeDir Directories="$(StandardScenePluginsDir)" />

    <ItemGroup>
      <StandardScenePluginCopyFile Include="$(TargetPath)" />
      <StandardScenePluginCopyFile Include="$(TargetDir)$(TargetName).pdb"
                                   Condition="Exists('$(TargetDir)$(TargetName).pdb')" />
      <StandardScenePluginCopyFile Include="$(TargetDir)$(TargetName).scene.json"
                                   Condition="Exists('$(TargetDir)$(TargetName).scene.json')" />
      <!-- Devices 插件运行时依赖 -->
      <StandardScenePluginCopyFile Include="$(TargetDir)leegKeys-sdk.dll"
                                   Condition="Exists('$(TargetDir)leegKeys-sdk.dll')" />
    </ItemGroup>

    <Copy SourceFiles="@(StandardScenePluginCopyFile)"
          DestinationFolder="$(StandardScenePluginsDir)"
          SkipUnchangedFiles="true" />

    <Message Importance="high"
             Text="[StandardScene] 已复制 $(MSBuildProjectName) 插件产物到 $(StandardScenePluginsDir)" />
  </Target>
</Project>
