This repository has been archived by the owner on Aug 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-windows.ps1
48 lines (41 loc) · 1.3 KB
/
build-windows.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
function Remove-Folder {
[CmdletBinding()]
Param (
[Parameter(Mandatory = $true)]
[System.String]
$Path
)
if (Test-Path $Path) {
Remove-Item $Path -Recurse
}
}
function Invoke-Dotnet {
[CmdletBinding()]
Param (
[Parameter(Mandatory = $true)]
[System.String]
$Command,
[Parameter(Mandatory = $true)]
[System.String]
$Arguments
)
$DotnetArgs = @()
$DotnetArgs = $DotnetArgs + $Command
$DotnetArgs = $DotnetArgs + ($Arguments -split '\s+')
[void]($Output = & dotnet $DotnetArgs)
# Should throw if the last command failed.
if ($LASTEXITCODE -ne 0) {
Write-Warning -Message ($Output -join "; ")
throw "There was an issue running the specified dotnet command."
}
}
# Remove all build artifacts
Remove-Folder -Path '.\build'
Remove-Folder -Path '.\RestAPI\bin'
Remove-Folder -Path '.\RestAPI\obj'
Remove-Folder -Path '.\RestAPI\build'
# Build the backend
Write-Host "Building backend..." -ForegroundColor Cyan
Invoke-Dotnet -Command 'tool' -Arguments 'restore'
Invoke-Dotnet -Command 'publish' -Arguments '.\RestAPI\RestAPI.csproj /p:PublishProfile=RestAPI\Properties\PublishProfiles\Windows-x64.pubxml -c Release'
Write-Host "Backend build complete" -ForegroundColor Green