-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.ps1
55 lines (45 loc) · 1.46 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
using namespace System.IO
using namespace System.Runtime.InteropServices
#Requires -Version 7.2
[CmdletBinding()]
param (
[Parameter()]
[string]
$Configuration = 'Debug',
[Parameter()]
[Architecture[]]
$Architecture = [RuntimeInformation]::OSArchitecture
# Kerberos.NET does not seem to support this
# [Parameter()]
# [switch]
# $PublishAot
)
$ErrorActionPreference = 'Stop'
$arguments = @(
'publish'
'--configuration', $Configuration
'--verbosity', 'quiet'
'-nologo'
"-p:Version=1.0.0"
# if ($PublishAot) {
# '-p:PublishAot=true'
# }
)
$binPath = [Path]::Combine($PSScriptRoot, 'bin')
if (Test-Path -LiteralPath $binPath) {
Remove-Item -LiteralPath $binPath -Recurse -Force
}
New-Item -Path $binPath -ItemType Directory | Out-Null
Get-ChildItem -LiteralPath $PSScriptRoot/src | ForEach-Object -Process {
foreach ($arch in $Architecture) {
$arch = $arch.ToString().ToLowerInvariant()
Write-Host "Compiling $($_.Name) for $arch" -ForegroundColor Cyan
$csproj = (Get-Item -Path "$([Path]::Combine($_.FullName, '*.csproj'))").FullName
$outputDir = [Path]::Combine($binPath, $_.Name, $arch)
New-Item -Path $outputDir -ItemType Directory -Force | Out-Null
dotnet @arguments --output $outputDir $csproj --runtime "win-$($arch.ToString().ToLowerInvariant())"
if ($LASTEXITCODE) {
throw "Failed to compiled code for $framework"
}
}
}