Skip to content

Commit 992ca76

Browse files
committed
Update build script
1 parent 3aaa8fc commit 992ca76

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

Build.ps1

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,42 @@
1-
echo "build: Build started"
1+
Write-Output "build: Build started"
22

33
Push-Location $PSScriptRoot
44

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

1010
& dotnet restore --no-cache
1111

12-
$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL];
13-
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
12+
$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$NULL -ne $env:APPVEYOR_REPO_BRANCH];
13+
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$NULL -ne $env:APPVEYOR_BUILD_NUMBER];
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 ""]
1715

18-
echo "build: Package version suffix is $suffix"
19-
echo "build: Build version suffix is $buildSuffix"
16+
Write-Output "build: Package version suffix is $suffix"
2017

21-
foreach ($src in ls src/*) {
18+
foreach ($src in Get-ChildItem src/*) {
2219
Push-Location $src
2320

24-
echo "build: Packaging project in $src"
21+
Write-Output "build: Packaging project in $src"
2522

26-
& dotnet build -c Release --version-suffix=$buildSuffix -p:EnableSourceLink=true
2723
if ($suffix) {
28-
& dotnet pack -c Release -o ..\..\artifacts --version-suffix=$suffix --no-build
24+
& dotnet pack -c Release --include-source -o ../../artifacts --version-suffix=$suffix
2925
} else {
30-
& dotnet pack -c Release -o ..\..\artifacts --no-build
26+
& dotnet pack -c Release --include-source -o ../../artifacts
3127
}
32-
if($LASTEXITCODE -ne 0) { exit 1 }
28+
if($LASTEXITCODE -ne 0) { throw "Packaging failed" }
3329

3430
Pop-Location
3531
}
3632

37-
foreach ($test in ls test/*.Tests) {
33+
foreach ($test in Get-ChildItem test/*.Tests) {
3834
Push-Location $test
3935

40-
echo "build: Testing project in $test"
36+
Write-Output "build: Testing project in $test"
4137

4238
& dotnet test -c Release
43-
if($LASTEXITCODE -ne 0) { exit 3 }
39+
if($LASTEXITCODE -ne 0) { throw "Testing failed" }
4440

4541
Pop-Location
4642
}

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ image:
44
- Visual Studio 2022
55
- Ubuntu
66
build_script:
7-
- ps: ./Build.ps1
7+
- pwsh: ./Build.ps1
88
for:
99
-
1010
matrix:
@@ -19,7 +19,7 @@ artifacts:
1919
deploy:
2020
- provider: NuGet
2121
api_key:
22-
secure: LE+O+3Zs0nz2F/+M4eDvKBhEBUpUV0t864vN/2dxwa7aIVqeU3pKSMjWRX+JWJ49
22+
secure: sDnchSg4TZIOK7oIUI6BJwFPNENTOZrGNsroGO1hehLJSvlHpFmpTwiX8+bgPD+Q
2323
on:
2424
branch: /^(main|dev)$/
2525
- provider: GitHub

0 commit comments

Comments
 (0)