-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.build.ps1
106 lines (84 loc) · 2.14 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
task . Compile, Build, ImportDebug, Test
Set-StrictMode -Version 4
############################################################
$SOLUTION_FILE = "$PSScriptRoot\source\ProxyCommand.sln"
$OBJECT_PATH = "$PSScriptRoot\source\x64"
$SCRIPT_PATH = "$PSScriptRoot\scripts"
$OBJECT_FILES = @(
"ProxyCommand.exe"
"ProxyCommand.pdb"
)
$MODULE_PATH = "$PSScriptRoot\ProxyCommand"
$MODULE_PATH_DEBUG = "$PSScriptRoot\debug\ProxyCommand"
############################################################
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 /nologo /v:minimal /p:Configuration=Debug
msbuild $SOLUTION_FILE /nologo /v:minimal /p:Configuration=Release
}
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 "$OBJECT_PATH\Release"
Copy-ObjectFiles $MODULE_PATH_DEBUG "$OBJECT_PATH\Debug"
}
}
task Test {
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
}