<!--
  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 Condition="'$(TargetArchitecture)' != 'x86'">$(RepoRootDir)\.dotnet</DotNetRoot>
  <DotNetRoot Condition="'$(TargetArchitecture)' == 'x86'">$(RepoRootDir)\.dotnet\x86</DotNetRoot>

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

  <ScriptRootDir>$(RepoRootDir)\src\SOS\SOS.UnitTests\Scripts</ScriptRootDir>
  <RootBinDir>$(RepoRootDir)\artifacts</RootBinDir>
  <InstallDir>$(RootBinDir)\bin\Windows_NT.$(TargetArchitecture).$(TargetConfiguration)</InstallDir>
  <LogDir>$(RootBinDir)\TestResults\$(TargetConfiguration)\sos.unittests_$(Timestamp)</LogDir>
  <DumpDir>$(RootBinDir)\tmp\$(TargetConfiguration)\dumps</DumpDir>
  <CDBPath>$(RootBinDir)\bin\SOS.UnitTests\$(TargetConfiguration)\netcoreapp2.0\publish\runtimes\win-$(TargetArchitecture)\native\cdb.exe</CDBPath>
  <CDBHelperExtension>$(InstallDir)\runcommand.dll</CDBHelperExtension>

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

  <TestWebApp>true</TestWebApp>
  <TestWebApp Condition="'$(TestLatestOnly)' == 'true'">false</TestWebApp>

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

  <TestDesktop>true</TestDesktop>
  <TestDesktop Condition="'$(TestLatestOnly)' == 'true'">false</TestDesktop>
  <TestDesktop Condition="'$(TargetArchitecture)' == 'arm64'">false</TestDesktop>

  <!-- Build the debuggee for this framework version but run it on latest -->
  <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '5')">netcoreapp3.1</BuildProjectFrameworkLatest>
  <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '3.1')">netcoreapp3.1</BuildProjectFrameworkLatest>
  <BuildProjectFrameworkLatest Condition="StartsWith('$(RuntimeVersionLatest)', '2.1')">netcoreapp2.1</BuildProjectFrameworkLatest>

  <DesktopFrameworkPath Condition="$(TargetArchitecture) == x64">$(WinDir)\Microsoft.Net\Framework64\v4.0.30319\</DesktopFrameworkPath>
  <DesktopFrameworkPath Condition="$(TargetArchitecture) != x64">$(WinDir)\Microsoft.Net\Framework\v4.0.30319\</DesktopFrameworkPath>
  <DesktopFramework>net462</DesktopFramework>

  <DebuggeeSourceRoot>$(RepoRootDir)\src\SOS\SOS.UnitTests\Debuggees</DebuggeeSourceRoot>
  <DebuggeeBuildProcess>sdk.prebuilt</DebuggeeBuildProcess>
  <DebuggeeBuildRoot>$(RootBinDir)</DebuggeeBuildRoot>
  <!-- Always build with x64 bit dotnet -->
  <CliPath>$(RepoRootDir)\.dotnet\dotnet.exe</CliPath>

  <NuGetPackageFeeds>
      myget.org dotnet-core=https://dotnet.myget.org/F/dotnet-core/api/v3/index.json;
      nuget.org=https://www.nuget.org/api/v2/
  </NuGetPackageFeeds>

  <Options>
    <!--
        .NET Core Runtime
     -->
    <Option>
      <TestProduct>ProjectK</TestProduct>
      <Options>
        <!--
            Default (prebuilt)
          -->
        <Option>
          <BuildProjectFramework>$(BuildProjectFrameworkLatest)</BuildProjectFramework>
          <RuntimeFrameworkVersion>$(RuntimeVersionLatest)</RuntimeFrameworkVersion>
        </Option>
        <Option Condition="'$(TestLatestOnly)' != 'true'">
          <BuildProjectFramework>netcoreapp3.1</BuildProjectFramework>
          <RuntimeFrameworkVersion>$(RuntimeVersion31)</RuntimeFrameworkVersion>
        </Option>
        <Option Condition="'$(TestLatestOnly)' != 'true'">
          <BuildProjectFramework>netcoreapp2.1</BuildProjectFramework>
          <RuntimeFrameworkVersion>$(RuntimeVersion21)</RuntimeFrameworkVersion>
        </Option>
        <!--
            SOS.StackAndOtherTests (cli because tested with full, embedded and portable PDBs)
          -->
        <Option>
          <DebuggeeBuildProcess>cli</DebuggeeBuildProcess>
          <DebuggeeBuildRoot>$(RootBinDir)\Debuggees</DebuggeeBuildRoot>
          <TestName>SOS.StackAndOtherTests</TestName>
          <Options>
            <Option>
              <BuildProjectFramework>$(BuildProjectFrameworkLatest)</BuildProjectFramework>
              <RuntimeFrameworkVersion>$(RuntimeVersionLatest)</RuntimeFrameworkVersion>
            </Option>
            <Option Condition="'$(TestLatestOnly)' != 'true'">
              <BuildProjectFramework>netcoreapp3.1</BuildProjectFramework>
              <RuntimeFrameworkVersion>$(RuntimeVersion31)</RuntimeFrameworkVersion>
            </Option>
            <Option Condition="'$(TestLatestOnly)' != 'true'">
              <BuildProjectFramework>netcoreapp2.1</BuildProjectFramework>
              <RuntimeFrameworkVersion>$(RuntimeVersion21)</RuntimeFrameworkVersion>
            </Option>
          </Options>
        </Option>
        <!--
            SOS.WebApp (runs only on Windows 2.x aspnetcore)
          -->
        <Option Condition="'$(TestWebApp)' == 'true'">
          <TestName>SOS.WebApp</TestName>
          <BuildProjectFramework>netcoreapp2.1</BuildProjectFramework>
          <RuntimeFrameworkVersion>$(RuntimeVersion21)</RuntimeFrameworkVersion>
          <FrameworkVersion>$(AspNetCoreVersion21)</FrameworkVersion>
        </Option>
        <!--
            SOS.WebApp3 and SOS.DualRuntimes (runs on 3.1 and latest aspnetcore)
          -->
        <Option Condition="'$(TestWebApp3)' == 'true'">
          <Options>
            <Option>
              <TestName>SOS.WebApp3</TestName>
            </Option>
            <Option>
              <TestName>SOS.DualRuntimes</TestName>
              <!-- The assembly path, class and function name of the desktop test code to load/run -->
              <DesktopTestParameters>$(RootBinDir)\bin\SymbolTestDll\$(TargetConfiguration)\$(DesktopFramework)\SymbolTestDll.dll SymbolTestDll.TestClass ThrowException</DesktopTestParameters>
            </Option>
          </Options>
          <Options>
            <Option>
              <BuildProjectFramework>$(BuildProjectFrameworkLatest)</BuildProjectFramework>
              <RuntimeFrameworkVersion>$(RuntimeVersionLatest)</RuntimeFrameworkVersion>
              <FrameworkVersion>$(AspNetCoreVersionLatest)</FrameworkVersion>
            </Option>
            <Option Condition="'$(TestLatestOnly)' != 'true'">
              <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>
      <SOSHostRuntime>$(DotNetRoot)\shared\Microsoft.NETCore.App\$(RuntimeFrameworkVersion)</SOSHostRuntime>
      <HostExe>$(DotNetRoot)\dotnet.exe</HostExe>
      <HostArgs>--fx-version $(FrameworkVersion)</HostArgs>
    </Option>
    <!--
        Desktop Runtime (debuggees cli built)
     -->
    <Option Condition="'$(TestDesktop)' == 'true'">
      <Options>
        <Option>
        </Option>
        <Option>
          <TestName>SOS.StackAndOtherTests</TestName>
        </Option>
      </Options>
      <TestProduct>Desktop</TestProduct>
      <DebuggeeBuildProcess>cli</DebuggeeBuildProcess>
      <DebuggeeBuildRoot>$(RootBinDir)\Debuggees</DebuggeeBuildRoot>
      <BuildProjectFramework>$(DesktopFramework)</BuildProjectFramework>
      <BuildProjectRuntime>win-$(TargetArchitecture)</BuildProjectRuntime>
      <DebugType>full</DebugType>
      <RuntimeSymbolsPath>$(DesktopFrameworkPath)</RuntimeSymbolsPath>
      <SOSHostRuntime>$(DotNetRoot)\shared\Microsoft.NETCore.App\$(RuntimeVersion21)</SOSHostRuntime>
    </Option>
  </Options>

  <SOSPath>$(InstallDir)\sos.dll</SOSPath>
  <DotNetDumpHost>$(DotNetRoot)\dotnet.exe</DotNetDumpHost>
  <DotNetDumpPath>$(RootBinDir)\bin\dotnet-dump\$(TargetConfiguration)\netcoreapp2.1\publish\dotnet-dump.dll</DotNetDumpPath>
  <DebuggeeDumpOutputRootDir>$(DumpDir)\$(TestProduct)\$(RuntimeFrameworkVersion)\$(BuildProjectFramework)</DebuggeeDumpOutputRootDir>
  <DebuggeeDumpInputRootDir>$(DebuggeeDumpOutputRootDir)</DebuggeeDumpInputRootDir>
</Configuration>
