1- param ([string ]$buildType = " Debug" , [string ]$dotnetDir = " c:\Program Files\dotnet" , [string ]$root = $PSScriptRoot , [string ]$failBuildOnTest = " YES" )
1+ param (
2+ [string ]$buildType = " Debug" ,
3+ [string ]$dotnetDir = " c:\Program Files\dotnet" ,
4+ [string ]$root = $PSScriptRoot ,
5+ [string ]$failBuildOnTest = " YES" ,
6+ [bool ]$runningInCI = $false )
27
38# ################################################ Functions ############################################################
49
@@ -31,7 +36,9 @@ Write-Host "dotnetDir: " $dotnetDir
3136Write-Host " root: " $root ;
3237Write-Host " failBuildOnTest: " $failBuildOnTest ;
3338Write-Host " slnFile: " $slnFile ;
39+ Write-Host " runningInCI: " $runningInCI ;
3440
41+ $runSettingsPath = $PSScriptRoot + " \build\CodeCoverage.runsettings"
3542[xml ]$buildConfiguration = Get-Content $PSScriptRoot \buildConfiguration.xml
3643$dotnetexe = " $dotnetDir \dotnet.exe" ;
3744$startTime = Get-Date
@@ -41,6 +48,13 @@ Write-Host "dotnetexe: " $dotnetexe;
4148
4249$ErrorActionPreference = " Stop"
4350
51+ $tempToUse = $env: TEMP ;
52+
53+ if ($runningInCI ) {
54+ # Temp dir used in ADO
55+ $tempToUse = " C:\__w\_temp" ;
56+ }
57+
4458$testProjects = $buildConfiguration.SelectNodes (" root/projects/test/project" )
4559foreach ($testProject in $testProjects )
4660{
@@ -50,10 +64,10 @@ foreach ($testProject in $testProjects)
5064
5165 $name = $testProject.name ;
5266 Write-Host " >>> Set-Location $root \test\$name "
53- pushd
67+ Push-Location
5468 Set-Location $root \test\$name
55- Write-Host " >>> Start-Process -Wait -PassThru -NoNewWindow $dotnetexe 'test $name .csproj' --filter category!=nonwindowstests --no-build --no-restore -nodereuse:false -v n -c $buildType "
56- $p = Start-Process - Wait - PassThru - NoNewWindow $dotnetexe " test $name .csproj --filter category!=nonwindowstests --no-build --no-restore -nodereuse:false -v n -c $buildType "
69+ Write-Host " >>> Start-Process -Wait -PassThru -NoNewWindow $dotnetexe 'test $name .csproj' --filter category!=nonwindowstests --no-build --no-restore -nodereuse:false -v n -c $buildType --collect "" Code Coverage "" --settings "" $runSettingsPath "" --logger trx --results-directory "" $tempToUse "" "
70+ $p = Start-Process - Wait - PassThru - NoNewWindow $dotnetexe " test $name .csproj --filter category!=nonwindowstests --no-build --no-restore -nodereuse:false -v n -c $buildType --collect "" Code Coverage "" --settings "" $runSettingsPath "" --logger trx --results-directory "" $tempToUse "" "
5771
5872 if ($p.ExitCode -ne 0 )
5973 {
@@ -68,7 +82,7 @@ foreach ($testProject in $testProjects)
6882 }
6983 $testExitCode = $p.ExitCode + $testExitCode
7084
71- popd
85+ Pop-Location
7286
7387 WriteSectionFooter(" End Test" );
7488 }
0 commit comments