forked from SychicBoy/NETReactorSlayer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
139 lines (129 loc) · 4.51 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
param(
[ValidateSet("all", "netframework", "net6.0-win32", "net6.0-win64", "net6.0-win-arm", "net6.0-win-arm64", "net6.0-linux64", "net6.0-linux-arm", "net6.0-linux-arm64", "net6.0-osx64", "netcoreapp3.1-win32", "netcoreapp3.1-win64", "netcoreapp3.1-win-arm", "netcoreapp3.1-win-arm64", "netcoreapp3.1-linux64", "netcoreapp3.1-linux-arm", "netcoreapp3.1-linux-arm64", "netcoreapp3.1-osx64")]
[string]$framework = 'all',
${-no-msbuild}
)
$ErrorActionPreference = 'Stop'
$configuration = 'Release'
function BuildNETFramework {
Write-Host 'Building .NET Framework x86 and x64 binaries'
if (${-no-msbuild}) {
dotnet build -v:m -c $configuration
if ($LASTEXITCODE) {
Write-Host
Write-Host ==========================
Write-Host "THE BUILD OPERATION ENCOUNTERED AN ERROR. EXIT CODE: $LASTEXITCODE" -ForegroundColor Red
exit $LASTEXITCODE
}
}
else {
msbuild -v:m -m -restore -t:Build -p:Configuration=$configuration
if ($LASTEXITCODE) {
Write-Host
Write-Host ==========================
Write-Host "THE BUILD OPERATION ENCOUNTERED AN ERROR. EXIT CODE: $LASTEXITCODE" -ForegroundColor Red
exit $LASTEXITCODE
}
}
}
function BuildNETCore {
param([string]$architecture, [string]$tfm)
Write-Host "Building .NET $architecture binaries"
$runtimeidentifier = "$architecture"
if (${-no-msbuild}) {
dotnet publish NETReactorSlayer.CLI\NETReactorSlayer.CLI.csproj -v:m -c $configuration -f $tfm -r $runtimeidentifier --self-contained -p:IncludeNativeLibrariesForSelfExtract=true -p:PublishTrimmed=True -p:PublishSingleFile=true
if ($LASTEXITCODE) {
Write-Host
Write-Host ==========================
Write-Host "THE BUILD OPERATION ENCOUNTERED AN ERROR. EXIT CODE: $LASTEXITCODE" -ForegroundColor Red
exit $LASTEXITCODE
}
}
else {
msbuild NETReactorSlayer.CLI\NETReactorSlayer.CLI.csproj -v:m -m -restore -t:Publish -p:Configuration=$configuration -p:TargetFramework=$tfm -p:RuntimeIdentifier=$runtimeidentifier -p:SelfContained=True -p:IncludeNativeLibrariesForSelfExtract=true -p:PublishTrimmed=True -p:PublishSingleFile=true
if ($LASTEXITCODE) {
Write-Host
Write-Host ==========================
Write-Host "THE BUILD OPERATION ENCOUNTERED AN ERROR. EXIT CODE: $LASTEXITCODE" -ForegroundColor Red
exit $LASTEXITCODE
}
}
}
if($framework -eq 'all') {
BuildNETFramework
BuildNETCore win-x86 "net6.0"
BuildNETCore win-x64 "net6.0"
BuildNETCore win-arm "net6.0"
BuildNETCore win-arm64 "net6.0"
BuildNETCore linux-x64 "net6.0"
BuildNETCore linux-arm "net6.0"
BuildNETCore linux-arm64 "net6.0"
BuildNETCore osx-x64 "net6.0"
BuildNETCore win-x86 "netcoreapp3.1"
BuildNETCore win-x64 "netcoreapp3.1"
BuildNETCore win-arm "netcoreapp3.1"
BuildNETCore win-arm64 "netcoreapp3.1"
BuildNETCore linux-x64 "netcoreapp3.1"
BuildNETCore linux-arm "netcoreapp3.1"
BuildNETCore linux-arm64 "netcoreapp3.1"
BuildNETCore osx-x64 "netcoreapp3.1"
Write-Host
Write-Host ==========================
Write-Host "BUILD OPERATION COMPLETED SUCCESSFULLY" -ForegroundColor Green
}
else {
if($framework -eq 'netframework'){
BuildNETFramework
}
elseif($framework -eq 'net6.0-win32'){
BuildNETCore win-x86 'net6.0'
}
elseif($framework -eq 'net6.0-win64'){
BuildNETCore win-x64 'net6.0'
}
elseif($framework -eq 'net6.0-win-arm'){
BuildNETCore win-arm 'net6.0'
}
elseif($framework -eq 'net6.0-win-arm64'){
BuildNETCore win-arm64 'net6.0'
}
elseif($framework -eq 'net6.0-linux64'){
BuildNETCore linux-x64 'net6.0'
}
elseif($framework -eq 'net6.0-linux-arm'){
BuildNETCore linux-arm 'net6.0'
}
elseif($framework -eq 'net6.0-linux-arm64'){
BuildNETCore linux-arm64 'net6.0'
}
elseif($framework -eq 'net6.0-osx64'){
BuildNETCore osx-x64 'net6.0'
}
elseif($framework -eq 'netcoreapp3.1-win32'){
BuildNETCore win-x86 'netcoreapp3.1'
}
elseif($framework -eq 'netcoreapp3.1-win64'){
BuildNETCore win-x64 'netcoreapp3.1'
}
elseif($framework -eq 'netcoreapp3.1-win-arm'){
BuildNETCore win-arm 'netcoreapp3.1'
}
elseif($framework -eq 'netcoreapp3.1-win-arm64'){
BuildNETCore win-arm64 'netcoreapp3.1'
}
elseif($framework -eq 'netcoreapp3.1-linux64'){
BuildNETCore linux-x64 'netcoreapp3.1'
}
elseif($framework -eq 'netcoreapp3.1-linux-arm'){
BuildNETCore linux-arm 'netcoreapp3.1'
}
elseif($framework -eq 'netcoreapp3.1-linux-arm64'){
BuildNETCore linux-arm64 'netcoreapp3.1'
}
elseif($framework -eq 'netcoreapp3.1-osx64'){
BuildNETCore osx-x64 'netcoreapp3.1'
}
Write-Host
Write-Host ==========================
Write-Host "BUILD OPERATION COMPLETED SUCCESSFULLY" -ForegroundColor Green
}