Skip to content

Commit 7316ece

Browse files
authored
Update Build.ps1 [skip ci]
1 parent 8d96753 commit 7316ece

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

Build.ps1

+24-15
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,56 @@ echo "build: Build started"
33
Push-Location $PSScriptRoot
44

55
if(Test-Path .\artifacts) {
6-
echo "build: Cleaning .\artifacts"
7-
Remove-Item .\artifacts -Force -Recurse
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];
14-
$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "master" -and $revision -ne "local"]
14+
$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 ls src/*) {
21+
foreach ($src in gci src/*) {
1922
Push-Location $src
2023

2124
echo "build: Packaging project in $src"
2225

23-
& dotnet pack -c Release -o ..\..\artifacts --version-suffix=$suffix
24-
if($LASTEXITCODE -ne 0) { exit 1 }
26+
& dotnet build -c Release --version-suffix=$buildSuffix
27+
28+
if($suffix) {
29+
& dotnet pack -c Release --include-source --no-build -o ../../artifacts --version-suffix=$suffix
30+
} else {
31+
& dotnet pack -c Release --include-source --no-build -o ../../artifacts
32+
}
33+
if($LASTEXITCODE -ne 0) { exit 1 }
2534

2635
Pop-Location
2736
}
2837

29-
foreach ($test in ls test/*.PerformanceTests) {
38+
foreach ($test in gci test/*.Tests) {
3039
Push-Location $test
3140

32-
echo "build: Building performance test project in $test"
41+
echo "build: Testing project in $test"
3342

34-
& dotnet build -c Release
35-
if($LASTEXITCODE -ne 0) { exit 2 }
43+
& dotnet test -c Release
44+
if($LASTEXITCODE -ne 0) { exit 3 }
3645

3746
Pop-Location
3847
}
3948

40-
foreach ($test in ls test/*.Tests) {
49+
foreach ($test in ls test/*.PerformanceTests) {
4150
Push-Location $test
4251

43-
echo "build: Testing project in $test"
52+
echo "build: Building performance test project in $test"
4453

45-
& dotnet test -c Release
46-
if($LASTEXITCODE -ne 0) { exit 3 }
54+
& dotnet build -c Release
55+
if($LASTEXITCODE -ne 0) { exit 2 }
4756

4857
Pop-Location
4958
}

0 commit comments

Comments
 (0)