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

  <!-- We are using a single TFM for this project, the drawback is that we cannot run benchmarks
       targeting other .NET runtime versions, such as net5.0 (PS7.1) and netcoreapp3.1 (PS7.0) -->
  <Import Project="../../Test.Common.props" />

  <PropertyGroup>
    <Description>PowerShell Performance Tests</Description>
    <AssemblyName>powershell-perf</AssemblyName>
    <OutputType>Exe</OutputType>

    <NoWarn>$(NoWarn);CS8002</NoWarn>
    <SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>

    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugType>portable</DebugType>
    <DebugSymbols>true</DebugSymbols>

    <!-- To run benchmarks targeting a specific package version, set the version to 'PERF_TARGET_VERSION' as an environment variable.
      Do not try passing in the value using '/property:' at command line, because
        1. 'dotnet run' doesn't respect '/property:' arguments;
        2. BenchmarkDotnet generates temporary project files that reference to this .csproj file,
           and '/property:' arguments won't be forwarded when building those temp projects. -->
    <PerfTargetVersion>$(PERF_TARGET_VERSION)</PerfTargetVersion>

    <!-- Test.Common.props sets TargetFramework to net6.0, we need to clear this value to be able to target multiple TFMs.
      But we do it only when 'PERF_TARGET_VERSION' was not specified. When it is specified, a specific version is being benchmarked
      and this version can be benchmarked only against single runtime version (because 'Microsoft.PowerShell.SDK' targets a single TFM). -->
    <TargetFramework Condition="'$(PerfTargetVersion)' == ''"></TargetFramework>
    <TargetFrameworks Condition="'$(TargetFramework)' == ''">netcoreapp3.1;net5.0;net6.0</TargetFrameworks>

    <PerfTargetVersion Condition="'$(PerfTargetVersion)' == '' AND '$(TargetFramework)' == 'net5.0'">7.1.3</PerfTargetVersion>
    <PerfTargetVersion Condition="'$(PerfTargetVersion)' == '' AND '$(TargetFramework)' == 'netcoreapp3.1'">7.0.6</PerfTargetVersion>
  </PropertyGroup>

  <PropertyGroup>
    <DelaySign>true</DelaySign>
    <AssemblyOriginatorKeyFile>../../../src/signing/visualstudiopublic.snk</AssemblyOriginatorKeyFile>
    <SignAssembly>true</SignAssembly>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="../dotnet-tools/BenchmarkDotNet.Extensions/BenchmarkDotNet.Extensions.csproj" />
  </ItemGroup>

  <ItemGroup Condition="'$(PerfTargetVersion)' == ''">
    <ProjectReference Include="../../../src/Microsoft.PowerShell.SDK/Microsoft.PowerShell.SDK.csproj" />
    <ProjectReference Include="../../../src/Microsoft.PowerShell.Commands.Diagnostics/Microsoft.PowerShell.Commands.Diagnostics.csproj" />
    <ProjectReference Include="../../../src/Microsoft.WSMan.Management/Microsoft.WSMan.Management.csproj" />
  </ItemGroup>

  <ItemGroup Condition="'$(PerfTargetVersion)' != ''">
    <!-- We have to specify all package references explicitly due to a .NET SDK bug: https://github.com/dotnet/sdk/issues/17013
      If the project references project A which references project B and we want to reference their packages for different TFMs,
      we have to explicitly reference package A and B. -->
    <PackageReference Include="Microsoft.PowerShell.SDK" Version="$(PerfTargetVersion)" />
    <PackageReference Include="Microsoft.PowerShell.Commands.Diagnostics" Version="$(PerfTargetVersion)" />
    <PackageReference Include="Microsoft.PowerShell.Commands.Management" Version="$(PerfTargetVersion)" />
    <PackageReference Include="Microsoft.PowerShell.Commands.Utility" Version="$(PerfTargetVersion)" />
    <PackageReference Include="Microsoft.PowerShell.ConsoleHost" Version="$(PerfTargetVersion)" />
    <PackageReference Include="Microsoft.PowerShell.Security" Version="$(PerfTargetVersion)" />
    <PackageReference Include="Microsoft.PowerShell.CoreCLR.Eventing" Version="$(PerfTargetVersion)" />
    <PackageReference Include="Microsoft.WSMan.Management" Version="$(PerfTargetVersion)" />
    <PackageReference Include="Microsoft.WSMan.Runtime" Version="$(PerfTargetVersion)" />
    <PackageReference Include="System.Management.Automation" Version="$(PerfTargetVersion)" />
  </ItemGroup>

</Project>
