<Project Sdk="Microsoft.Build.NoTargets">

  <PropertyGroup>
    <TargetFramework>$(CoreSdkTargetFramework)</TargetFramework>
    <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
    <CopyBuildOutputToPublishDirectory>false</CopyBuildOutputToPublishDirectory>
    <ProduceReferenceAssembly>false</ProduceReferenceAssembly>
    <NativeVersionFile>$(ArtifactsObjDir)sdk_version.h</NativeVersionFile>
  </PropertyGroup>

  <ItemGroup>
    <!-- The MicrosoftSignedWixVersion property comes from the Arcade SDK DefaultVersions.props -->
    <PackageReference Include="Microsoft.Signed.Wix" Version="$(MicrosoftSignedWixVersion)" GeneratePathProperty="true" />
  </ItemGroup>

  <ItemGroup>
    <!-- See: https://github.com/dotnet/arcade/tree/main/src/Microsoft.DotNet.CMake.Sdk#referencing-native-assets-with-nativeprojectreference -->
    <NativeProjectReference Include="CMakeLists.txt" CMakeProject="finalizer.nativeproj" BuildNative="true" />
  </ItemGroup>

  <Target Name="GenerateSdkVersionFile" BeforeTargets="CoreCompile" DependsOnTargets="GenerateNativeVersionFile" />

  <!-- This target needs to run before the native project reference is built. -->
  <Target Name="CopyWixSdk" AfterTargets="Restore" BeforeTargets="Build">
    <ItemGroup>
      <WixLib Include="$(WixSdkPath)vs2017\lib\**\*.*" />
      <WixInclude Include="$(WixSdkPath)inc\**\*.*" />
    </ItemGroup>

    <!-- Copy all the lib files for x86, x64, and arm64. -->
    <Copy SourceFiles="@(WixLib)" DestinationFiles="@(WixLib->'$(ArtifactsDir)WixSdk\lib\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
    <Copy SourceFiles="@(WixInclude)" DestinationFolder="$(ArtifactsDir)WixSdk\inc" SkipUnchangedFiles="true" />
  </Target>

  <!-- This imports the CMake SDK and because BuildNative is true, it builds the native project. -->
  <!-- See: https://github.com/dotnet/arcade/tree/main/src/Microsoft.DotNet.CMake.Sdk#referencing-native-assets-with-nativeprojectreference -->
  <Import Project="ProjectReference.targets" Sdk="Microsoft.DotNet.CMake.Sdk" />

</Project>