forked from eclipse-aaspe/server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BuildForRelease.ps1
89 lines (72 loc) · 2.03 KB
/
BuildForRelease.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
param(
[Parameter(HelpMessage = "If set, cleans up the previous build instead of performing a new one")]
[switch]
$clean = $false
)
<#
.DESCRIPTION
This script builds the solution for debugging (manual or automatic testing).
#>
$ErrorActionPreference = "Stop"
Import-Module (Join-Path $PSScriptRoot Common.psm1) -Function `
AssertDotnet, `
GetArtefactsDir
function CopyContentForDemo($Destination)
{
$contentForDemoDir = Join-Path (Split-Path -Parent $PSScriptRoot) "content-for-demo"
if (!(Test-Path $contentForDemoDir))
{
throw "The directory with the content for demo does not exist: $contentForDemoDir"
}
Write-Host "Copying content for demo from $contentForDemoDir to: $Destination"
Get-ChildItem -Path $contentForDemoDir `
| Copy-Item -Destination $Destination -Recurse -Container -Force
}
function Main
{
Set-Location $PSScriptRoot
$baseBuildDir = Join-Path $( GetArtefactsDir ) "build" `
| Join-Path -ChildPath "Release"
if ($clean)
{
Write-Host "dotnet clean'ing ..."
dotnet clean
if ($LASTEXITCODE -ne 0)
{
throw "Failed to dotnet clean."
}
Write-Host "Removing the build directory: $baseBuildDir"
Remove-Item -LiteralPath $baseBuildDir -Force -Recurse
}
else
{
AssertDotnet
##
# Build dotnet targets
##
$dotnetTargets = $(
"AasxServerBlazor"
"AasxServerCore"
"AasxServerWindows"
)
foreach ($target in $dotnetTargets)
{
$buildDir = Join-Path $baseBuildDir $target
Write-Host "Publishing with dotnet $target to: $buildDir"
dotnet publish -c Release -o $buildDir $target
if ($LASTEXITCODE -ne 0)
{
throw "Failed to dotnet publish: $target"
}
CopyContentForDemo -Destination $buildDir
}
}
}
$previousLocation = Get-Location; try
{
Main
}
finally
{
Set-Location $previousLocation
}