-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.ps1
executable file
·81 lines (69 loc) · 2.2 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
param(
[Parameter()]
[string] $BuildId = (Get-Date).ToString("yyyyMMddhhmmss"),
[Parameter()]
[string] $BuildNumber = 2810,
[Parameter()]
[switch] $CleanDevDependencies
)
$ErrorActionPreference = "Stop"
[string] $RepoRoot = $PSScriptRoot
[string] $BuildConfiguration = "Release"
[string] $TargetFramework = "net8.0"
[string] $BaseUrl = ./tools/Get-BaseUrl.ps1
Write-Host "Using build-id '$BuildId'"
Write-Host "Using build-number '$BuildNumber'"
Write-Host "Using configuration '$BuildConfiguration'"
Write-Host "Using framework '$TargetFramework'"
Write-Host "Using base url '$BaseUrl'"
$ReportScript = "$RepoRoot/tools/test-reports.ps1"
[string] $DistFolder = "$RepoRoot/dist"
if (Test-Path $DistFolder)
{
Write-Host "dist folder from previous run exists, removing now."
Remove-Item $DistFolder -Recurse -Force
}
dotnet restore
if ($LASTEXITCODE -ne 0)
{
Write-Error "Restore Failure"
}
dotnet build --no-restore --configuration $BuildConfiguration /p:BuildId=$BuildId /p:BuildNumber=$BuildNumber /p:Version=1.0.0.$BuildNumber
if ($LASTEXITCODE -ne 0)
{
Write-Error "Build Failure"
}
dotnet format --verify-no-changes
if ($LASTEXITCODE -ne 0)
{
Write-Error "Formatting Failure"
}
# https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-test
dotnet test --no-restore --no-build --configuration $BuildConfiguration ./test/Unit/Test.Unit.csproj
# dotnet test --configuration $BuildConfiguration --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=lcov /p:CoverletOutput=TestResults/lcov.info
if ($LASTEXITCODE -ne 0)
{
Write-Error "Test Failure"
}
# Disabled until https://github.com/SpecFlowOSS/SpecFlow/issues/2591 gets fixed
# & $ReportScript -BuildConfiguration $BuildConfiguration
dotnet "src/Component/Client/SiteGenerator/bin/$BuildConfiguration/$TargetFramework/Kaylumah.Ssg.Client.SiteGenerator.dll" Site:Url=$BaseUrl
if ($LASTEXITCODE -ne 0)
{
Write-Error "Run Failure"
}
# https://docs.microsoft.com/en-us/powershell/scripting/samples/managing-current-location?view=powershell-7.2
try
{
Set-Location $DistFolder
npm i
npm run build:prod
}
finally
{
Set-Location $RepoRoot
}
if ($CleanDevDependencies)
{
& "./tools/Clean-Dist.ps1"
}