-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathpublish.ps1
62 lines (51 loc) · 1.54 KB
/
publish.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
#!/usr/bin/env pwsh
[CmdletBinding(PositionalBinding = $false)]
param(
[ValidateSet('Debug', 'Release')]
$Configuration = $null,
$OutputDir = $null,
$ExampleDir = $null,
[string]
$example,
[string]
$runtime
)
Set-StrictMode -Version 1
$ErrorActionPreference = 'Stop'
#
# Main
#
if (!$Configuration) {
$Configuration = 'Release'
}
if (!$OutputDir) {
$OutputDir = Split-Path $MyInvocation.MyCommand.Path
$OutputDir = [io.path]::combine($OutputDir, 'Publish')
}
if ($example -eq 'win32') {
$ExampleName = 'CoreHook.FileMonitor'
}
if ($example -eq 'uwp') {
$ExampleName = 'CoreHook.Uwp.FileMonitor'
}
if ($example -eq 'unix') {
$ExampleName = 'CoreHook.Unix.FileMonitor'
}
$ExamplesDir = 'examples'
$ExampleHookName = 'Hook'
$ExampleDir = [io.path]::combine($ExamplesDir, $example, $ExampleName)
$ExampleOutputDir = [io.path]::combine($OutputDir, $example, $runtime)
$ExampleHookDir = $ExampleDir + '.' + $ExampleHookName
$ExampleHookOutputDir = [io.path]::combine($OutputDir, $example, $runtime, $ExampleHookName)
function exec([string]$_cmd) {
write-host -ForegroundColor DarkGray ">>> $_cmd $args"
$ErrorActionPreference = 'Continue'
& $_cmd @args
$ErrorActionPreference = 'Stop'
if ($LASTEXITCODE -ne 0) {
write-error "Failed with exit code $LASTEXITCODE"
exit 1
}
}
exec dotnet publish $ExampleDir --configuration $Configuration -r $runtime -o $ExampleOutputDir
exec dotnet publish $ExampleHookDir --configuration $Configuration -r $runtime -o $ExampleHookOutputDir