-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ps1
43 lines (36 loc) · 1.51 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
[CmdletBinding(PositionalBinding = $false)]
param(
[switch] $CreatePackages,
[switch] $RunTest
)
Write-Host "Run Parameters:" -ForegroundColor Cyan
Write-Host " CreatePackages: $CreatePackages"
Write-Host " RunTests: $RunTests"
Write-Host " dotnet --version:" (dotnet --version)
$packageOutputFolder = "$PSScriptRoot\.nupkgs"
Write-Host "Restoring all projects..." -ForegroundColor "Magenta"
dotnet restore
Write-Host "Done restoring." -ForegroundColor "Green"
Write-Host "Building all projects..." -ForegroundColor "Magenta"
dotnet build -c Release --no-restore
Write-Host "Done building." -ForegroundColor "Green"
# ----------TESTS------------
if ($RunTest) {
Write-Host "Running tests: " -ForegroundColor "Magenta"
dotnet test -c Release
if ($LastExitCode -ne 0) {
Write-Host "Error with tests, aborting build." -Foreground "Red"
Exit 1
}
Write-Host "Tests passed!" -ForegroundColor "Green"
}
# ----------PACKING------------
if ($CreatePackages) {
mkdir -Force $packageOutputFolder | Out-Null
Write-Host "Clearing existing $packageOutputFolder..." -NoNewline
Get-ChildItem $packageOutputFolder | Remove-Item
Write-Host "done." -ForegroundColor "Green"
Write-Host "Packing ..." -ForegroundColor "Magenta"
dotnet pack ".\src\XdtExtensions\XdtExtensions.csproj" -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg -c Release /p:PackageOutputPath=$packageOutputFolder
}
Write-Host "Build Complete." -ForegroundColor "Green"