<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <!-- Detect OS for build -->
  <PropertyGroup>
    <BUILD_OS Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">Windows</BUILD_OS>
    <BUILD_OS Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">OSX</BUILD_OS>
    <BUILD_OS Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">Linux</BUILD_OS>
  </PropertyGroup>

  <!-- Set OS vars -->
  <PropertyGroup Condition="'$(BUILD_OS)' == 'Windows'">
    <DefineConstants>$(DefineConstants);OS_WINDOWS</DefineConstants>
  </PropertyGroup>
  <PropertyGroup Condition="'$(BUILD_OS)' == 'OSX'">
    <DefineConstants>$(DefineConstants);OS_OSX</DefineConstants>
  </PropertyGroup>
  <PropertyGroup Condition="'$(BUILD_OS)' == 'Linux'">
    <DefineConstants>$(DefineConstants);OS_LINUX</DefineConstants>
  </PropertyGroup>

  <!-- Set Platform/bitness vars -->
  <PropertyGroup Condition="'$(BUILD_OS)' == 'Windows' AND ('$(PackageRuntime)' == 'win-x64' OR '$(PackageRuntime)' == '')">
    <DefineConstants>$(DefineConstants);X64</DefineConstants>
  </PropertyGroup>
  <PropertyGroup Condition="'$(BUILD_OS)' == 'Windows' AND '$(PackageRuntime)' == 'win-x86'">
    <DefineConstants>$(DefineConstants);X86</DefineConstants>
  </PropertyGroup>
  <PropertyGroup Condition="'$(BUILD_OS)' == 'Windows' AND '$(PackageRuntime)' == 'win-arm64'">
    <DefineConstants>$(DefineConstants);ARM64</DefineConstants>
  </PropertyGroup>

  <PropertyGroup Condition="'$(BUILD_OS)' == 'OSX' AND '$(PackageRuntime)' == 'osx-x64'">
    <DefineConstants>$(DefineConstants);X64</DefineConstants>
  </PropertyGroup>
  <PropertyGroup Condition="'$(BUILD_OS)' == 'OSX' AND '$(PackageRuntime)' == 'osx-arm64'">
    <DefineConstants>$(DefineConstants);ARM64</DefineConstants>
  </PropertyGroup>

  <PropertyGroup Condition="'$(BUILD_OS)' == 'Linux' AND ('$(PackageRuntime)' == 'linux-x64' OR '$(PackageRuntime)' == '')">
    <DefineConstants>$(DefineConstants);X64</DefineConstants>
  </PropertyGroup>
  <PropertyGroup Condition="'$(BUILD_OS)' == 'Linux' AND '$(PackageRuntime)' == 'linux-arm'">
    <DefineConstants>$(DefineConstants);ARM</DefineConstants>
  </PropertyGroup>
  <PropertyGroup Condition="'$(BUILD_OS)' == 'Linux' AND '$(PackageRuntime)' == 'linux-arm64'">
    <DefineConstants>$(DefineConstants);ARM64</DefineConstants>
  </PropertyGroup>

  <!-- Set TRACE/DEBUG vars -->
  <PropertyGroup>
    <DefineConstants>$(DefineConstants);TRACE</DefineConstants>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)' == 'Debug'">
    <DefineConstants>$(DefineConstants);DEBUG</DefineConstants>
  </PropertyGroup>

  <!-- Set Treat tarnings as errors -->
  <PropertyGroup>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
  </PropertyGroup>

  <PropertyGroup>
    <!-- Enable NuGet package auditing -->
    <NuGetAudit>true</NuGetAudit>
    <!-- Audit direct and transitive packages -->
    <NuGetAuditMode>all</NuGetAuditMode>
    <!-- Report low, moderate, high and critical advisories -->
    <NuGetAuditLevel>moderate</NuGetAuditLevel>
  </PropertyGroup>
</Project>
