forked from Exiled-Team/EXILED
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
55 lines (46 loc) · 1.11 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
#! pwsh
param (
[Switch]$BuildNuGet
)
$Projects = @(
'Exiled.Loader',
'Exiled.API',
'Exiled.Permissions',
'Exiled.Events',
'Exiled.Updater',
'Exiled.CreditTags',
'Exiled.Example',
'Exiled.CustomItems',
'Exiled.CustomRoles'
)
function Execute {
param (
[string]$Cmd
)
foreach ($Project in $Projects) {
Invoke-Expression ([string]::Join(' ', $Cmd, $Project, $args))
CheckLastOperationStatus
}
}
function CheckLastOperationStatus {
if ($? -eq $false) {
Exit 1
}
}
function GetSolutionVersion {
[XML]$PropsFile = Get-Content Exiled.props
$Version = $PropsFile.Project.PropertyGroup[2].Version
$Version = $Version.'#text'.Trim()
return $Version
}
# Restore projects
Execute 'dotnet restore'
# Build projects
Execute 'dotnet build' '-c release'
# Build a NuGet package if needed
if ($BuildNuGet) {
$Version = GetSolutionVersion
$Year = [System.DateTime]::Now.ToString('yyyy')
Write-Host "Generating NuGet package for version $Version"
nuget pack Exiled/Exiled.nuspec -Version $Version -Properties Year=$Year
}