-
Notifications
You must be signed in to change notification settings - Fork 1
/
.build.ps1
124 lines (100 loc) · 2.64 KB
/
.build.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
112
113
114
115
116
117
118
119
120
121
122
123
124
task . Compile, Build, ImportDebug
Set-StrictMode -Version 4
############################################################
$SOURCE_PATH = "$PSScriptRoot\source\Horker.Math"
$SCRIPT_PATH = "$PSScriptRoot\scripts"
$MODULE_PATH = "$PSScriptRoot\psmath"
$MODULE_PATH_DEBUG = "$PSScriptRoot\debug\psmath"
$SOLUTION_FILE = "$PSScriptRoot\source\Horker.Math.sln"
$OBJECT_FILES = @(
"Accord.dll"
"Accord.Math.Core.dll"
"Accord.Math.dll"
"Accord.Statistics.dll"
"Horker.Math.dll"
"Horker.Math.pdb"
)
#$HELP_INPUT = "$SOURCE_PATH\bin\Release\Horker.Math.dll"
#$HELP_INTERM = "$SOURCE_PATH\bin\Release\Horker.Data.dll-Help.xml"
#$HELP_OUTPUT = "$MODULE_PATH\Horker.Data.dll-Help.xml"
#$HELPGEN = "$PSScriptRoot\vendor\XmlDoc2CmdletDoc.0.2.10\tools\XmlDoc2CmdletDoc.exe"
############################################################
function New-Folder2 {
param(
[string]$Path
)
try {
$null = New-Item -Type Directory $Path -EA Stop
Write-Host -ForegroundColor DarkCyan "$Path created"
}
catch {
Write-Host -ForegroundColor DarkYellow $_
}
}
function Copy-Item2 {
param(
[string]$Source,
[string]$Dest
)
try {
Copy-Item $Source $Dest -EA Stop
Write-Host -ForegroundColor DarkCyan "Copy from $Source to $Dest done"
}
catch {
Write-Host -ForegroundColor DarkYellow $_
}
}
function Remove-Item2 {
param(
[string]$Path
)
try {
Remove-Item $Path -EA Stop
Write-Host -ForegroundColor DarkCyan "$Path removed"
}
catch {
Write-Host -ForegroundColor DarkYellow $_
}
}
############################################################
task Compile {
msbuild $SOLUTION_FILE /p:Configuration=Debug /nologo /v:minimal
msbuild $SOLUTION_FILE /p:Configuration=Release /nologo /v:minimal
}
task Build {
. {
$ErrorActionPreference = "Continue"
function Copy-ObjectFiles {
param(
[string]$targetPath,
[string]$objectPath
)
New-Folder2 $targetPath
Copy-Item2 "$SCRIPT_PATH\*" $targetPath
$OBJECT_FILES | foreach {
$path = Join-Path $objectPath $_
Copy-Item2 $path $targetPath
}
}
Copy-ObjectFiles $MODULE_PATH "$SOURCE_PATH\bin\Release"
Copy-ObjectFiles $MODULE_PATH_DEBUG "$SOURCE_PATH\bin\Debug"
}
}
#task BuildHelp `
# -Inputs $HELP_INPUT `
# -Outputs $HELP_OUTPUT `
#{
# . $HELPGEN $HELP_INPUT
#
# Copy-Item $HELP_INTERM $MODULE_PATH
#}
task Test Build, ImportDebug, {
Invoke-Pester "$PSScriptRoot\tests"
}
task ImportDebug {
Import-Module $MODULE_PATH_DEBUG -Force
}
task Clean {
Remove-Item2 "$MODULE_PATH\*" -Force -Recurse -EA Continue
Remove-Item2 "$MODULE_PATH_DEBUG\*" -Force -Recurse -EA Continue
}