-
Notifications
You must be signed in to change notification settings - Fork 2
/
DotNetTest.Task.ps1
29 lines (26 loc) · 1.01 KB
/
DotNetTest.Task.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Add-BuildTask DotNetTest @{
# This task should be skipped if there are no C# projects to build
If = $dotnetTestProjects
Inputs = {
Get-ChildItem (Split-Path $dotnetProjects) -Recurse -File -Filter *.cs
| Where-Object FullName -NotMatch "[\\/]obj[\\/]"
}
Outputs = {
(Get-ChildItem $TestResultsRoot -Filter *.trx -Recurse -ErrorAction Ignore) ?? $TestResultsRoot
}
Jobs = "DotNetBuild", {
# make sure the coverage tool is available
dotnet tool update --global dotnet-coverage
$local:options = @{
"-configuration" = $configuration
"-results-directory" = $TestResultsRoot
} + $script:dotnetOptions
if ($Script:CollectCoverage) {
$options["-collect"] = "Code Coverage"
}
foreach ($project in $dotnetTestProjects) {
Write-Build Gray "dotnet test $project --no-build --logger trx" @options
dotnet test $project --no-build --logger trx @options
}
}
}