Skip to content

Commit 455da01

Browse files
committed
Update build script with hopes of running consistently on all platforms
1 parent 536b072 commit 455da01

File tree

1 file changed

+26
-35
lines changed

1 file changed

+26
-35
lines changed

Build.ps1

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,68 +2,59 @@ echo "build: Build started"
22

33
Push-Location $PSScriptRoot
44

5-
if (Test-Path .\artifacts) {
6-
echo "build: Cleaning .\artifacts"
7-
Remove-Item .\artifacts -Force -Recurse
5+
if(Test-Path .\artifacts) {
6+
echo "build: Cleaning .\artifacts"
7+
Remove-Item .\artifacts -Force -Recurse
88
}
99

1010
& dotnet restore --no-cache
1111

1212
$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL];
1313
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
1414
$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "main" -and $revision -ne "local"]
15+
$commitHash = $(git rev-parse --short HEAD)
16+
$buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""]
1517

16-
echo "build: Version suffix is $suffix"
18+
echo "build: Package version suffix is $suffix"
19+
echo "build: Build version suffix is $buildSuffix"
1720

18-
foreach ($src in dir src/*) {
21+
foreach ($src in ls src/*) {
1922
Push-Location $src
2023

21-
echo "build: Packaging project in $src"
24+
echo "build: Packaging project in $src"
2225

23-
& dotnet pack -c Release -o ..\..\artifacts --version-suffix=$suffix -p:ContinuousIntegrationBuild=true
24-
if ($LASTEXITCODE -ne 0) { exit 1 }
26+
& dotnet build -c Release --version-suffix=$buildSuffix
2527

26-
Pop-Location
27-
}
28-
29-
foreach ($test in dir test/*.PerformanceTests) {
30-
Push-Location $test
31-
32-
echo "build: Building performance test project in $test"
33-
34-
& dotnet build -c Release
35-
if ($LASTEXITCODE -ne 0) { exit 2 }
28+
if($suffix) {
29+
& dotnet pack -c Release --include-source --no-build -o ../../artifacts --version-suffix=$suffix -p:ContinuousIntegrationBuild=true
30+
} else {
31+
& dotnet pack -c Release --include-source --no-build -o ../../artifacts -p:ContinuousIntegrationBuild=true
32+
}
33+
if($LASTEXITCODE -ne 0) { exit 1 }
3634

3735
Pop-Location
3836
}
3937

40-
foreach ($test in dir test/*.Tests) {
38+
foreach ($test in ls test/*.Tests) {
4139
Push-Location $test
4240

43-
echo "build: Testing project in $test"
41+
echo "build: Testing project in $test"
4442

45-
if ($PSVersionTable.Platform -eq "Unix") {
46-
& dotnet test -c Release -f netcoreapp3.1
47-
& dotnet test -c Release -f net6.0
48-
} else {
49-
& dotnet test -c Release
50-
}
51-
52-
if ($LASTEXITCODE -ne 0) { exit 3 }
43+
& dotnet test -c Release
44+
if($LASTEXITCODE -ne 0) { exit 3 }
5345

5446
Pop-Location
5547
}
5648

57-
if ($PSVersionTable.Platform -eq "Unix") {
58-
Push-Location sample/Sample
49+
foreach ($test in ls test/*.PerformanceTests) {
50+
Push-Location $test
5951

60-
& dotnet run -f netcoreapp3.1 -c Release --run-once
61-
if ($LASTEXITCODE -ne 0) { exit 4 }
52+
echo "build: Building performance test project in $test"
6253

63-
& dotnet run -f net6.0 -c Release --run-once
64-
if ($LASTEXITCODE -ne 0) { exit 4 }
54+
& dotnet build -c Release
55+
if($LASTEXITCODE -ne 0) { exit 2 }
6556

6657
Pop-Location
6758
}
6859

69-
Pop-Location
60+
Pop-Location

0 commit comments

Comments
 (0)