-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuildTest.ps1
111 lines (98 loc) · 3.19 KB
/
BuildTest.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
Class ProjectRef
{
[string] $ProjectLocation;
[string] $TestsLocation;
ProjectRef([string] $project, [string] $tests)
{
$this.ProjectLocation = $project;
$this.TestsLocation = $tests;
}
BuildAndTest([string] $name)
{
Write-Host "Building packages for project '$name'";
dotnet build $this.ProjectLocation -c Release | Write-Host -ForegroundColor DarkGray;
if ($LastExitCode -ne 0)
{
Write-Host "Failed to build project" -ForegroundColor Red;
return;
}
if (-not [String]::IsNullOrEmpty($this.TestsLocation))
{
Write-Host "Testing project '$name'";
dotnet test $this.TestsLocation -c Release | Write-Host -ForegroundColor DarkGray;
if ($LastExitCode -ne 0)
{
Write-Host "Package not published because of failed tests" -ForegroundColor Red;
return;
}
}
Write-Host "Packing project '$name'";
dotnet pack $this.ProjectLocation -c Release -o D:\nugets | Write-Host -ForegroundColor DarkGray;
if ($LastExitCode -ne 0)
{
Write-Host "Packing failed" -ForegroundColor Red;
return;
}
}
}
if ($args.Length -eq 0)
{
Write-Host "No args given.";
return;
}
$projects = @{
"Collections" = [ProjectRef]::new("src\JiiLib.Collections\JiiLib.Collections.csproj", "test\JiiLib.Collections.Tests\JiiLib.Collections.Tests.csproj");
"Components" = [ProjectRef]::new("src\JiiLib.Components\JiiLib.Components.csproj", [String]::Empty);
"Constraints" = [ProjectRef]::new("src\JiiLib.Constraints\JiiLib.Constraints.csproj", "test\JiiLib.Constraints.Tests\JiiLib.Constraints.Tests.csproj");
"Media" = [ProjectRef]::new("src\JiiLib.Media\JiiLib.Media.csproj", "test\JiiLib.Media.Tests\JiiLib.Media.Tests.csproj");
};
# if ($args.Length -eq 1 -and $args[0] -eq "-clean")
# {
# Write-Host "Cleaning up bins.";
# foreach ($dir in [Directory]::EnumerateDirectories("src\", "bin", [SearchOption]::AllDirectories))
# {
# [Directory]::Delete($dir, true);
# }
# Write-Host "Cleaning up objs.";
# foreach ($dir in [Directory]::EnumerateDirectories("src\", "obj", [SearchOption]::AllDirectories))
# {
# [Directory]::Delete($dir, true);
# }
# Write-Host "Cleaning up docs.";
# foreach ($file in [Directory]::EnumerateFiles("docs\api\", "*.yml"))
# {
# [File]::Delete($file);
# }
# foreach ($file in [Directory]::EnumerateFiles("docs\site\api\", "*.html"))
# {
# [File]::Delete($file);
# }
# return;
# }
if ($args.Length -eq 1 -and $args[0] -eq "-all")
{
foreach ($key in $projects.Keys)
{
$projects[$key].BuildAndTest($key);
}
}
else
{
foreach ($arg in $args)
{
if ($projects.ContainsKey($arg))
{
$projects[$arg].BuildAndTest($arg);
}
}
}
if ($LastExitCode -eq 0)
{
Write-Host "Building docs";
docfx "docs\docfx.json" | Write-Host -ForegroundColor DarkGray;
if ($LastExitCode -ne 0)
{
Write-Host "Docs building failed" -ForegroundColor Red;
return;
}
}