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

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

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

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

  <CliPath>$(DotNetRoot)\dotnet.exe</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>
    <!--
        .NET Core Runtime
     -->
    <Option>
      <TestProduct>ProjectK</TestProduct>
      <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 full, embedded and portable PDBs)
          -->
        <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 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>
              <SetSymbolServer>-ms</SetSymbolServer>
              <!-- 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 Condition="'$(AspNetCoreVersionLatest)' != ''">
              <DebuggeeBuildProcess>cli</DebuggeeBuildProcess>
              <DebuggeeBuildRoot>$(RootBinDir)\Debuggees\SingleFile</DebuggeeBuildRoot>
              <BuildProjectFramework>$(BuildProjectFrameworkLatest)</BuildProjectFramework>
              <RuntimeFrameworkVersion>$(SingleFileRuntimeLatestVersion)</RuntimeFrameworkVersion>
              <PublishSingleFile>true</PublishSingleFile>
              <SetSymbolServer>-ms</SetSymbolServer>
              <BuildProjectRuntime>$(TargetRid)</BuildProjectRuntime>
            </Option> 
            <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>
      
      <!-- Single-file debuggees don't need the host -->
      <HostExe Condition="'$(PublishSingleFile)' != 'true'">$(DotNetRoot)\dotnet.exe</HostExe>
      <HostArgs Condition="'$(PublishSingleFile)' != 'true'">--fx-version $(FrameworkVersion)</HostArgs>
    </Option>
    <!--
        Desktop Runtime (debuggees cli built)
     -->
    <Option Condition="'$(TestDesktop)' == 'true'">
      <Options>
        <Option>
        </Option>
        <Option>
          <TestName>SOS.StackAndOtherTests</TestName>
        </Option>
        <Option>
          <TestName>DotnetDumpCommands</TestName>
        </Option>
      </Options>
      <TestProduct>Desktop</TestProduct>
      <DebuggeeBuildProcess>cli</DebuggeeBuildProcess>
      <DebuggeeBuildRoot>$(RootBinDir)\Debuggees</DebuggeeBuildRoot>
      <BuildProjectFramework>$(DesktopFramework)</BuildProjectFramework>
      <BuildProjectRuntime>$(TargetRid)</BuildProjectRuntime>
      <DebugType>full</DebugType>
      <RuntimeSymbolsPath>$(DesktopFrameworkPath)</RuntimeSymbolsPath>
      <SetHostRuntime>-netfx</SetHostRuntime>
    </Option>
  </Options>

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