<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
  <Import Project="$(ProjectDir)../Drivers/CommonBuildProperties.items" />
   <!-- Public API tracking slows down the build by a lot. 
  <Import Project="$(ProjectDir)../Drivers/ApiTracking.items "/>
  -->
  <PropertyGroup>
    <ProjectGuid>{5C315C78-1F97-4B16-81AA-917284969DFE}</ProjectGuid>
    <AssemblyName>Reko.Core</AssemblyName>
    <RootNamespace>Reko.Core</RootNamespace>
    <OutputType>Library</OutputType>
    <TargetFramework>net6.0</TargetFramework>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
    <Configurations>Debug;Release</Configurations>
    <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <DefineConstants>TRACE</DefineConstants>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='UnixDebug|AnyCPU'">
    <DefineConstants>TRACE</DefineConstants>
  </PropertyGroup>
  <ItemGroup>
    <Compile Remove="Serialization\DecompilerDiscoveries.cs" />
    <Compile Remove="Serialization\EnumType_v1.cs" />
    <Compile Remove="Serialization\SignatureSerializer.cs" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
  </ItemGroup>

  <Target Name="GenerateGitHash" BeforeTargets="CoreCompile">
    <!-- names the obj/.../CustomAssemblyInfo.cs file -->
    <Exec Command="git rev-parse --short HEAD" ConsoleToMSBuild="true" IgnoreExitCode="true">
      <Output TaskParameter="ConsoleOutput" PropertyName="GitRevParseOutput" />
      <Output TaskParameter="ExitCode" PropertyName="GitRevParseExitCode" />
    </Exec>
    <PropertyGroup Condition="$(GitRevParseExitCode)==0">
      <SourceRevisionId>$(GitRevParseOutput)</SourceRevisionId>
    </PropertyGroup>
    <PropertyGroup Condition="$(GitRevParseExitCode)!=0">
      <SourceRevisionId>unknown</SourceRevisionId>
    </PropertyGroup>
    <PropertyGroup>
      <CustomAssemblyInfoFile>$(IntermediateOutputPath)AssemblyData.Extra.cs</CustomAssemblyInfoFile>
    </PropertyGroup>
    <!-- includes the CustomAssemblyInfo for compilation into your project -->
    <ItemGroup>
      <Compile Include="$(CustomAssemblyInfoFile)" />
    </ItemGroup>
    <!-- defines the AssemblyMetadata attribute that will be written -->
    <ItemGroup>
      <AssemblyAttributes Include="AssemblyMetadata">
        <_Parameter1>GitHash</_Parameter1>
        <_Parameter2>$(SourceRevisionId)</_Parameter2>
      </AssemblyAttributes>
    </ItemGroup>
    <!-- writes the attribute to the customAssemblyInfo file -->
    <WriteCodeFragment Language="C#" OutputFile="$(CustomAssemblyInfoFile)" AssemblyAttributes="@(AssemblyAttributes)" />
  </Target>


</Project>
