<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>$(NetToolMinimum)</TargetFramework>
    <OutputType>Exe</OutputType>
    <IsPackable>true</IsPackable>
    <IsShippingPackage>true</IsShippingPackage>
    <PackAsTool>true</PackAsTool>
    <ToolCommandName>apicompat</ToolCommandName>
    <PackageDescription>Tool to perform api compatibility checks on assemblies and packages.</PackageDescription>
  </PropertyGroup>

  <ItemGroup>
    <EmbeddedResource Update="Resources.resx" GenerateSource="true" SubType="Designer" Generator="MSBuild:_GenerateResxSource" ClassName="Microsoft.DotNet.ApiCompat.Resources" ManifestResourceName="Microsoft.DotNet.ApiCompat.Resources" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="System.CommandLine" />
    <PackageReference Include="NuGet.Packaging" />
    <PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
    <ProjectReference Include="..\Microsoft.DotNet.PackageValidation\Microsoft.DotNet.PackageValidation.csproj" />
    <ProjectReference Include="..\Microsoft.DotNet.ApiCompatibility\Microsoft.DotNet.ApiCompatibility.csproj" />
  </ItemGroup>

  <!-- Move code analysis assemblies into a sub directory so that they can be conditionally resolved. -->
  <Target Name="UpdateMicrosoftCodeAnalysisFilesForBuild"
          AfterTargets="ResolveAssemblyReferences">
    <ItemGroup>
      <ReferenceCopyLocalPaths Condition="$([System.String]::new('%(Filename)').StartsWith('Microsoft.CodeAnalysis'))"
                               DestinationSubDirectory="codeanalysis\%(ReferenceCopyLocalPaths.DestinationSubDirectory)" />
    </ItemGroup>
  </Target>

  <Target Name="UpdateMicrosoftCodeAnalysisFilesForPublish"
          AfterTargets="_ResolveCopyLocalAssetsForPublish"
          BeforeTargets="_HandlePackageFileConflictsForPublish">
    <ItemGroup>
      <_ResolvedCopyLocalPublishAssets Condition="$([System.String]::new('%(Filename)').StartsWith('Microsoft.CodeAnalysis'))"
                                       DestinationSubDirectory="codeanalysis\%(_ResolvedCopyLocalPublishAssets.DestinationSubDirectory)" />
    </ItemGroup>
  </Target>

  <Import Project="..\Microsoft.DotNet.ApiCompat.Shared\Microsoft.DotNet.ApiCompat.Shared.projitems" Label="Shared" />

</Project>
