<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup Condition="'$(TestNuPkg)' != 'true'">
    <PseudoPackage>$(SrcRoot)dnne-pkg/bin/$(Configuration)/pkg/</PseudoPackage>
    <AfterMicrosoftNETSdkTargets>$(PseudoPackage)build/DNNE.targets</AfterMicrosoftNETSdkTargets>
  </PropertyGroup>

  <ItemGroup Condition="'$(TestNuPkg)' != 'true'">
    <Analyzer Include="$(PseudoPackage)analyzers/dotnet/cs/dnne-analyzers.dll" />
  </ItemGroup>

  <Import Condition="'$(TestNuPkg)' != 'true'" Project="$(PseudoPackage)build/DNNE.props" />

  <PropertyGroup>
    <TargetFrameworks>$(DnneTargetFramework)</TargetFrameworks>
    <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('Windows')) AND '$(DnneLanguage)' == 'c99'">$(TargetFrameworks);net472</TargetFrameworks>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
    <RollForward>Major</RollForward>
    <GenerateDocumentationFile>true</GenerateDocumentationFile>
    <!-- Disable warnings about missing comments -->
    <NoWarn>1591</NoWarn>

    <!-- A source generator is supplying attributes, so always emit that asset. -->
    <EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>

    <EnableDynamicLoading>true</EnableDynamicLoading>
    <DnneAddGeneratedBinaryToProject>true</DnneAddGeneratedBinaryToProject>
    <DnneCompilerUserFlags Condition="'$(BuildAsCPPWithMSVC)'=='true'">/TP </DnneCompilerUserFlags>
    <DnneCompilerCommand Condition="'$(BuildWithGCC)'=='true'">gcc</DnneCompilerCommand>
    <DnneCompilerCommand Condition="'$(BuildWithGPP)'=='true'">g++</DnneCompilerCommand>
    <DnneCompilerCommand Condition="'$(BuildWithClangPP)'=='true'">clang++</DnneCompilerCommand>

    <!-- Include the override option for dnne_abort() -->
    <DnneCompilerUserFlags Condition="'$(DnneLanguage)' != 'rust'">$(DnneCompilerUserFlags) $(MSBuildThisFileDirectory)override.c</DnneCompilerUserFlags>

    <!-- Rust: pass cfg flags for custom platform guards used in the test assembly -->
    <DnneCompilerUserFlags Condition="'$(DnneLanguage)' == 'rust'">--cfg set_assembly_platform --cfg set_module_platform --cfg set_type_platform --cfg __set_platform__ --cfg set_method_platform</DnneCompilerUserFlags>

    <!-- When targeting .NET Framework we only use a subset of files -->
    <EnableDefaultCompileItems Condition="$(TargetFramework.StartsWith('net4'))">false</EnableDefaultCompileItems>
  </PropertyGroup>

  <ItemGroup Condition="'$(EnableDefaultCompileItems)' == 'false'">
    <Compile Include="IntExports.cs" />
  </ItemGroup>

  <PropertyGroup Condition="'$(TestNuPkg)' == 'true' AND '$(RefLocalBuild)'=='true'">
    <RestoreSources>$(SrcRoot)dnne-pkg/bin/$(Configuration)</RestoreSources>
  </PropertyGroup>

  <ItemGroup Condition="'$(TestNuPkg)' == 'true'">
    <PackageReference Include="DNNE" Version="2.*" />
  </ItemGroup>
</Project>
