forked from SpecFlowOSS/SpecFlow-Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildandtest.ps1
78 lines (65 loc) · 2.35 KB
/
buildandtest.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
$skipTestExecution = ('*ExternalDataSample\Specs.sln', '*GherkinFormattingExamples\GherkinFormattingExamples.sln', '*WinForms\WinForms.sln', '*WPF\WPF.sln', '*Android Mobile App\Android Mobile App.sln')
function Get-MSBuild
{
If ($vsWhere = Get-Command "vswhere.exe" -ErrorAction SilentlyContinue)
{
$vsWhere = $vsWhere.Path
}
ElseIf (Test-Path "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe")
{
$vsWhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
}
Else
{
Write-Error "vswhere not found. Aborting." -ErrorAction Stop
}
Write-Host "vswhere found at: $vsWhere" -ForegroundColor Yellow
$path = &$vsWhere -prerelease -latest -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe
Write-Host "MSBuild found at: $path" -ForegroundColor Yellow
return $path
}
ForEach ($file in get-childitem . -recurse | where {$_.extension -like "*sln"})
{
$fullname = $file.fullname
# MSBuild contains old specflow versions, do not touch it
if (!($fullname -match 'MSBuild') -And !($fullname -match 'Webinars'))
{
Write-Output "File name: $file"
Write-Output "Fullpath: $fullname"
# dotnet test restores and builds the solution
if (!(($skipTestExecution | %{$fullname -like $_}) -contains $true))
{
# it has a local nuget feed, so build the nuget package first
if ($fullname -match 'SampleMethodTagDecorator')
{
$generatorPlugin = $fullname.Replace('SampleMethodTagDecorator.sln', 'GeneratorPlugin\SampleGeneratorPlugin.csproj')
Write-Output $generatorPlugin
iex "dotnet build '$generatorPlugin'"
}
iex "dotnet test '$fullname'"
if ($lastexitcode -ne 0)
{
break;
}
}
else
{
Write-Output "Test execution of '$fullname' was skipped because it contains failing tests. Building solution."
if ($fullname -match 'Android Mobile App.sln')
{
$msbuild = Get-MSBuild
$expression = "& '$msbuild' -restore '$fullname'"
Invoke-Expression $expression
}
else
{
iex "dotnet build '$fullname'"
}
if ($lastexitcode -ne 0)
{
break;
}
}
Write-Output "------------------------------------------------------------------------------------------------------------"
}
}