<!--
  The xunit tests in Debugger.Tests aren't truly unit tests - they depend on other stuff that may
  not be in the same directory. This file configures the tests to find what they need. At the moment
  this file is generated in a hard coded way to support running from the bin directory on our git
  based build, but once we understand the different environments the tests will need to run in we
  can figure out the right build and deployment strategy for each. Hopefully this configuration offers
  enough flexibility that the tests themselves don't need to change.
-->

<Configuration>
  <RepoRootDir>../../../../..</RepoRootDir>
  <DotNetRoot>$(RepoRootDir)/.dotnet-test</DotNetRoot>

  <Import ConfigFile="Debugger.Tests.Common.txt" />
  <Import ConfigFile="$(DotNetRoot)/Debugger.Tests.Versions.txt" />

  <TestProduct>ProjectK</TestProduct>
  <ScriptRootDir>$(RepoRootDir)/src/SOS/SOS.UnitTests/Scripts</ScriptRootDir>
  <RootBinDir>$(RepoRootDir)/artifacts</RootBinDir>
  <InstallDir>$(RootBinDir)/bin/$(OS).$(TargetArchitecture).$(TargetConfiguration)</InstallDir>
  <LogDir>$(RootBinDir)/TestResults/$(TargetConfiguration)/sos.unittests_$(Timestamp)</LogDir>
  <DumpDir>$(RootBinDir)/tmp/$(TargetConfiguration)\dumps</DumpDir>

  <TestWebApp3>true</TestWebApp3>
  <TestWebApp3 Condition="'$(InternalReleaseTesting)' == 'true'">false</TestWebApp3>

  <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '7')">net7.0</BuildProjectFrameworkLatest>
  <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '5')">net5.0</BuildProjectFrameworkLatest>
  <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '6')">net6.0</BuildProjectFrameworkLatest>
  <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '3.1')">netcoreapp3.1</BuildProjectFrameworkLatest>

  <DebuggeeSourceRoot>$(RepoRootDir)/src/SOS/SOS.UnitTests/Debuggees</DebuggeeSourceRoot>
  <DebuggeeBuildProcess>sdk.prebuilt</DebuggeeBuildProcess>
  <DebuggeeBuildRoot>$(RootBinDir)</DebuggeeBuildRoot>

  <CliPath>$(DotNetRoot)/dotnet</CliPath>

  <NuGetPackageFeeds>
      dotnet7=https://dnceng.pkgs.visualstudio.com/public/_packaging/dotnet7/nuget/v3/index.json;
      dotnet6=https://dnceng.pkgs.visualstudio.com/public/_packaging/dotnet6/nuget/v3/index.json;
      dotnet-core=https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json;
      dotnet-public=https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json
  </NuGetPackageFeeds>

  <Options>
    <!--
        Single file (debuggees cli built)
     -->
    <Option Condition="'$(RuntimeVersionLatest)' != ''">
      <DebuggeeBuildProcess>cli</DebuggeeBuildProcess>
      <DebuggeeBuildRoot>$(RootBinDir)/Debuggees/SingleFile</DebuggeeBuildRoot>
      <BuildProjectFramework>$(BuildProjectFrameworkLatest)</BuildProjectFramework>
      <RuntimeFrameworkVersion>$(SingleFileRuntimeLatestVersion)</RuntimeFrameworkVersion>
      <PublishSingleFile>true</PublishSingleFile>
      <!-- Add the symbol server so SOS can find DAC/DBI for single file apps which
           may not have been built with the runtime pointed by RuntimeSymbolsPath
           since we use the arcade provided SDK (in .dotnet) to build them. -->
      <SetSymbolServer>-ms</SetSymbolServer>
      <BuildProjectRuntime>$(TargetRid)</BuildProjectRuntime>
    </Option>
    <Option Condition="'$(RuntimeVersion60)' != ''">
      <DebuggeeBuildProcess>cli</DebuggeeBuildProcess>
      <DebuggeeBuildRoot>$(RootBinDir)/Debuggees/SingleFile</DebuggeeBuildRoot>
      <BuildProjectFramework>net6.0</BuildProjectFramework>
      <RuntimeFrameworkVersion>$(SingleFileRuntime60Version)</RuntimeFrameworkVersion>
      <PublishSingleFile>true</PublishSingleFile>
      <SetSymbolServer>-ms</SetSymbolServer>
      <BuildProjectRuntime>$(TargetRid)</BuildProjectRuntime>
    </Option>
    <!--
        Default (prebuilt)
      -->
    <Option Condition="'$(RuntimeVersionLatest)' != ''">
      <BuildProjectFramework>$(BuildProjectFrameworkLatest)</BuildProjectFramework>
      <RuntimeFrameworkVersion>$(RuntimeVersionLatest)</RuntimeFrameworkVersion>
      <SetHostRuntime>$(DotNetRoot)/shared/Microsoft.NETCore.App/$(RuntimeFrameworkVersion)</SetHostRuntime>
    </Option>
    <Option Condition="'$(RuntimeVersion60)' != ''">
      <BuildProjectFramework>net6.0</BuildProjectFramework>
      <RuntimeFrameworkVersion>$(RuntimeVersion60)</RuntimeFrameworkVersion>
    </Option>
    <Option Condition="'$(RuntimeVersion31)' != ''">
      <BuildProjectFramework>netcoreapp3.1</BuildProjectFramework>
      <RuntimeFrameworkVersion>$(RuntimeVersion31)</RuntimeFrameworkVersion>
      <SetHostRuntime>$(DotNetRoot)/shared/Microsoft.NETCore.App/$(RuntimeFrameworkVersion)</SetHostRuntime>
    </Option>
    <!--
        SOS.StackAndOtherTests (cli because tested with embedded, portable PDBs and single-file)
      -->
    <Option>
      <DebuggeeBuildProcess>cli</DebuggeeBuildProcess>
      <DebuggeeBuildRoot>$(RootBinDir)/Debuggees</DebuggeeBuildRoot>
      <TestName>SOS.StackAndOtherTests</TestName>
      <Options>
        <Option Condition="'$(RuntimeVersionLatest)' != ''">
          <DebuggeeBuildRoot>$(RootBinDir)/Debuggees/SingleFile</DebuggeeBuildRoot>
          <BuildProjectFramework>$(BuildProjectFrameworkLatest)</BuildProjectFramework>
          <RuntimeFrameworkVersion>$(SingleFileRuntimeLatestVersion)</RuntimeFrameworkVersion>
          <PublishSingleFile>true</PublishSingleFile>
          <SetSymbolServer>-ms</SetSymbolServer>
          <BuildProjectRuntime>$(TargetRid)</BuildProjectRuntime>
        </Option>
        <Option Condition="'$(RuntimeVersion60)' != ''">
          <DebuggeeBuildRoot>$(RootBinDir)/Debuggees/SingleFile</DebuggeeBuildRoot>
          <BuildProjectFramework>net6.0</BuildProjectFramework>
          <RuntimeFrameworkVersion>$(SingleFileRuntime60Version)</RuntimeFrameworkVersion>
          <PublishSingleFile>true</PublishSingleFile>
          <SetSymbolServer>-ms</SetSymbolServer>
          <BuildProjectRuntime>$(TargetRid)</BuildProjectRuntime>
        </Option>
        <Option Condition="'$(RuntimeVersionLatest)' != ''">
          <BuildProjectFramework>$(BuildProjectFrameworkLatest)</BuildProjectFramework>
          <RuntimeFrameworkVersion>$(RuntimeVersionLatest)</RuntimeFrameworkVersion>
        </Option>
        <Option Condition="'$(RuntimeVersion60)' != ''">
          <BuildProjectFramework>net6.0</BuildProjectFramework>
          <RuntimeFrameworkVersion>$(RuntimeVersion60)</RuntimeFrameworkVersion>
        </Option>
        <Option Condition="'$(RuntimeVersion31)' != ''">
          <BuildProjectFramework>netcoreapp3.1</BuildProjectFramework>
          <RuntimeFrameworkVersion>$(RuntimeVersion31)</RuntimeFrameworkVersion>
        </Option>
      </Options>
    </Option>
    <!--
        SOS.WebApp3 (runs on 3.1 and latest aspnetcore)
      -->
    <Option Condition="'$(TestWebApp3)' == 'true'">
      <TestName>SOS.WebApp3</TestName>
      <Options>
        <Option Condition="'$(AspNetCoreVersionLatest)' != ''">
          <BuildProjectFramework>$(BuildProjectFrameworkLatest)</BuildProjectFramework>
          <RuntimeFrameworkVersion>$(RuntimeVersionLatest)</RuntimeFrameworkVersion>
        </Option>
        <Option Condition="'$(AspNetCoreVersion60)' != ''">
          <BuildProjectFramework>net6.0</BuildProjectFramework>
          <RuntimeFrameworkVersion>$(RuntimeVersion60)</RuntimeFrameworkVersion>
          <FrameworkVersion>$(AspNetCoreVersion60)</FrameworkVersion>
        </Option>
        <Option Condition="'$(AspNetCoreVersion31)' != ''">
          <BuildProjectFramework>netcoreapp3.1</BuildProjectFramework>
          <RuntimeFrameworkVersion>$(RuntimeVersion31)</RuntimeFrameworkVersion>
          <FrameworkVersion>$(AspNetCoreVersion31)</FrameworkVersion>
        </Option>
      </Options>
    </Option>
  </Options>

  <FrameworkVersion Condition="'$(FrameworkVersion)' == ''">$(RuntimeFrameworkVersion)</FrameworkVersion>
  <RuntimeSymbolsPath>$(DotNetRoot)/shared/Microsoft.NETCore.App/$(RuntimeFrameworkVersion)</RuntimeSymbolsPath>
  <LLDBHelperScript>$(ScriptRootDir)/lldbhelper.py</LLDBHelperScript>

  <!-- Single-file debuggees don't need the host -->
  <HostExe Condition="'$(PublishSingleFile)' != 'true'">$(DotNetRoot)/dotnet</HostExe>
  <HostArgs Condition="'$(PublishSingleFile)' != 'true'">--fx-version $(FrameworkVersion)</HostArgs>

  <Options>
    <Option Condition="$(OS) == Linux">
      <SOSPath>$(InstallDir)/libsosplugin.so</SOSPath>
    </Option>
    <Option Condition="$(OS) == OSX">
      <SOSPath>$(InstallDir)/libsosplugin.dylib</SOSPath>
    </Option>
  </Options>

  <DotNetDumpHost>$(DotNetRoot)/dotnet</DotNetDumpHost>
  <DotNetDumpPath>$(RootBinDir)/bin/dotnet-dump/$(TargetConfiguration)/netcoreapp3.1/publish/dotnet-dump.dll</DotNetDumpPath>
  <DebuggeeDumpOutputRootDir>$(DumpDir)/$(TestProduct)/$(RuntimeFrameworkVersion)/$(BuildProjectFramework)</DebuggeeDumpOutputRootDir>
  <DebuggeeDumpInputRootDir>$(DebuggeeDumpOutputRootDir)</DebuggeeDumpInputRootDir>

</Configuration>
