File: C\Users\cloudtest\.nuget\packages\microsoft.dotnet.arcade.sdk\9.0.0-beta.24572.2\tools\Tests.targets
Project: ..\..\..\src\Package\DevDivPackage\DevDivPackage.csproj (MSBuildFiles)
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. -->
<Project InitialTargets="ErrorForMissingTestRunner">
 
  <PropertyGroup Condition="'$(IsTestProject)' == 'true'">
    <AutoGenerateBindingRedirects Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">true</AutoGenerateBindingRedirects>
 
    <_GetTestsToRunTarget Condition="'$(TargetFrameworks)' == ''">_InnerGetTestsToRun</_GetTestsToRunTarget>
    <_GetTestsToRunTarget Condition="'$(TargetFrameworks)' != ''">_OuterGetTestsToRun</_GetTestsToRunTarget>
 
    <!-- The runtime to run tests on: 'Core', 'Mono', 'Full' (desktop FX). -->
    <TestRuntime Condition="'$(TestRuntime)' == '' and '$(TargetFrameworkIdentifier)' == '.NETCoreApp'">Core</TestRuntime>
    <TestRuntime Condition="'$(TestRuntime)' == '' and '$(MSBuildRuntimeType)' == 'Mono'">Mono</TestRuntime>
    <TestRuntime Condition="'$(TestRuntime)' == '' and '$(OS)' == 'Windows_NT'">Full</TestRuntime>
 
    <TestRunnerName Condition="'$(TestRunnerName)' == ''">XUnit</TestRunnerName>
    <TestRunnerName Condition="'$(UsingToolXUnit)' == 'false'"></TestRunnerName>
 
    <!--
      Look for the specified test runner in the building repository first.
      If we can't find it see if the requested test runner provided by the Arcade SDK.
    -->
    <TestRunnerTargets>$(RepositoryEngineeringDir)$(TestRunnerName)\$(TestRunnerName).targets</TestRunnerTargets>
    <TestRunnerTargets Condition="!Exists($(TestRunnerTargets))">$(MSBuildThisFileDirectory)$(TestRunnerName)\$(TestRunnerName).targets</TestRunnerTargets>
  </PropertyGroup>
 
  <Target Name="ErrorForMissingTestRunner"
          Condition="'$(IsTestProject)' == 'true' AND '$(TestRunnerName)' != ''">
    <Error Condition="!Exists($(TestRunnerTargets))" Text="Test runner $(TestRunnerName) is invalid."/>
  </Target>
 
  <PropertyGroup Condition="'$(IsTestProject)' == 'true' and '$(TestArchitectures)' == ''">
    <TestArchitectures>$(PlatformTarget)</TestArchitectures>
    <TestArchitectures Condition="'$(PlatformTarget)' == '' or '$(PlatformTarget)' == 'AnyCpu'">x64</TestArchitectures>
  </PropertyGroup>
 
  <Target Name="Test" DependsOnTargets="$(_GetTestsToRunTarget);RunTests" Condition="'$(IsUnitTestProject)' == 'true' or '$(IsPerformanceTestProject)' == 'true'" />
  <Target Name="IntegrationTest" DependsOnTargets="$(_GetTestsToRunTarget);RunTests" Condition="'$(IsIntegrationTestProject)' == 'true'" />
 
  <ItemGroup>
    <_TestArchitectureItems Include="$(TestArchitectures)" />
  </ItemGroup>
 
  <!-- Using Inputs/Outputs just to loop over test architectures -->
  <Target Name="_InnerGetTestsToRun"
          Outputs="%(_TestArchitectureItems.Identity)"
          Returns="@(TestToRun)"
          Condition="'$(TestRuntime)' != '' and '$(SkipTests)' != 'true' and
                     ('$(TestTargetFrameworks)' == '' or $([System.String]::new(';$(TestTargetFrameworks);').Contains(';$(TargetFramework);')))">
 
    <PropertyGroup>
      <_TestArchitecture>%(_TestArchitectureItems.Identity)</_TestArchitecture>
      <_ResultFileNameNoExt>$(MSBuildProjectName)_$(TargetFramework)_$(_TestArchitecture)</_ResultFileNameNoExt>
 
      <!-- Send the logs into the default location, unless overriden by the consumer -->
      <TestResultsLogDir Condition=" '$(TestResultsLogDir)' == '' ">$(ArtifactsLogDir)</TestResultsLogDir>
    </PropertyGroup>
 
    <ItemGroup>
      <TestToRun Include="$(TargetPath)">
        <TargetFramework>$(TargetFramework)</TargetFramework>
        <TargetFrameworkIdentifier>$(TargetFrameworkIdentifier)</TargetFrameworkIdentifier>
        <TargetFrameworkVersion>$(TargetFrameworkVersion)</TargetFrameworkVersion>
        <TestRuntime>$(TestRuntime)</TestRuntime>
        <TestTimeout>$(TestTimeout)</TestTimeout>
        <Architecture>$(_TestArchitecture)</Architecture>
        <EnvironmentDisplay>$(TargetFramework)|$(_TestArchitecture)</EnvironmentDisplay>
        <ResultsFilePathWithoutExtension>$(_ResultFileNameNoExt)</ResultsFilePathWithoutExtension>
        <ResultsXmlPath>$(ArtifactsTestResultsDir)$(_ResultFileNameNoExt).xml</ResultsXmlPath>
        <ResultsTrxPath>$(ArtifactsTestResultsDir)$(_ResultFileNameNoExt).trx</ResultsTrxPath>
        <ResultsHtmlPath>$(ArtifactsTestResultsDir)$(_ResultFileNameNoExt).html</ResultsHtmlPath>
        <ResultsStdOutPath>$(TestResultsLogDir)$(_ResultFileNameNoExt).log</ResultsStdOutPath>
        <TestRunnerAdditionalArguments>$(TestRunnerAdditionalArguments)</TestRunnerAdditionalArguments>
      </TestToRun>
    </ItemGroup>
  </Target>
 
  <Target Name="_OuterGetTestsToRun" Returns="@(TestToRun)">
    <ItemGroup>
      <_TargetFramework Include="$(TargetFrameworks)" />
    </ItemGroup>
    <MSBuild Projects="$(MSBuildProjectFile)"
             Condition="'$(TargetFrameworks)' != ''"
             Targets="_InnerGetTestsToRun"
             Properties="TargetFramework=%(_TargetFramework.Identity)">
      <Output ItemName="TestToRun" TaskParameter="TargetOutputs" />
    </MSBuild>
  </Target>
 
  <!-- Import specialized targets files of supported test runners -->
  <Import Project="$(TestRunnerTargets)" Condition="'$(IsTestProject)' == 'true' and '$(TestRunnerName)' != '' and Exists('$(TestRunnerTargets)')"/>
  
  <!-- Allow for repo specific Test targets such as rerunning tests -->
  <Import Project="$(RepositoryEngineeringDir)Tests.targets" Condition="Exists('$(RepositoryEngineeringDir)Tests.targets')" />
 
</Project>