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

  <PropertyGroup>
    <TargetFramework>$(CoreSdkTargetFramework)</TargetFramework>
    <CopyBuildOutputToOutputDirectory>false</CopyBuildOutputToOutputDirectory>
    <GenerateDependencyFile>false</GenerateDependencyFile>
    <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
    <GenerateRuntimeConfigurationFiles>false</GenerateRuntimeConfigurationFiles>
    <ExcludeFromSourceBuild>true</ExcludeFromSourceBuild>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.DotNet.MSBuildSdkResolver" Version="$(MicrosoftDotNetMSBuildSdkResolverPackageVersion)" ExcludeAssets="all" GeneratePathProperty="true"/>
    <PackageReference Include="Microsoft.NETCore.App.Runtime.win-x86" Version="$(MicrosoftNETCoreAppRuntimePackageVersion)" ExcludeAssets="all" GeneratePathProperty="true" />
    <PackageReference Include="Microsoft.NETCore.App.Runtime.win-x64" Version="$(MicrosoftNETCoreAppRuntimePackageVersion)" ExcludeAssets="all" GeneratePathProperty="true" />
    <PackageReference Include="Microsoft.NETCore.App.Runtime.win-arm64" Version="$(MicrosoftNETCoreAppRuntimePackageVersion)" ExcludeAssets="all" GeneratePathProperty="true" />
  </ItemGroup>

  <Target Name="GenerateLayout" Condition="'$(OS)' == 'Windows_NT'" BeforeTargets="AfterBuild">
    <Message Importance="High" Text="$(MSBuildProjectName) -&gt; $(OutputPath)" />

    <RemoveDir Directories="$(OutputPath)" />
    <MakeDir Directories="$(OutputPath)" />

    <ItemGroup>
      <_SdkResolverSrc Include="$(PkgMicrosoft_NETCore_App_Runtime_win-x86)\runtimes\win-x86\native\hostfxr.dll" Arch="x86\" />
      <_SdkResolverSrc Include="$(PkgMicrosoft_NETCore_App_Runtime_win-x64)\runtimes\win-x64\native\hostfxr.dll" Arch="x64\" />
      <_SdkResolverSrc Include="$(PkgMicrosoft_NETCore_App_Runtime_win-arm64)\runtimes\win-arm64\native\hostfxr.dll" Arch="arm64\" />
      <_SdkResolverSrc Include="$(PkgMicrosoft_DotNet_MSBuildSdkResolver)\lib\net472\**\*.dll" Arch="" />
      <_SdkResolverDst Include="@(_SdkResolverSrc->'$(OutputPath)%(Arch)%(RecursiveDir)%(Filename)%(Extension)')" />
    </ItemGroup>

    <Copy SourceFiles="@(_SdkResolverSrc)" DestinationFiles="@(_SdkResolverDst)" />
  </Target>

</Project>
