-
Notifications
You must be signed in to change notification settings - Fork 206
/
Build.ps1
48 lines (40 loc) · 1.17 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
param (
[string[]]$projects = @(),
[string]$buildNumber,
[string]$packageSuffix = "0",
[bool]$isLocal = $false,
[string]$outputDirectory = (Join-Path -Path $PSScriptRoot -ChildPath "buildoutput"),
[bool]$pack = $false,
[string]$Configuration
)
if (-not $Configuration) {
Write-Host "Configuration not specified, defaulting to 'Release'" -ForegroundColor Yellow
$Configuration = 'Release'
}
if ($null -eq $buildNumber) {
throw 'Parameter $buildNumber cannot be null or empty. Exiting script.'
}
if ($isLocal){
$packageSuffix = "dev" + [datetime]::UtcNow.Ticks.ToString()
Write-Host "Local build - setting package suffixes to $packageSuffix" -ForegroundColor Yellow
}
dotnet --version
if (-not $?) { exit 1 }
foreach ($project in $projects)
{
# This assumes we've already built the package
if ($pack)
{
$cmd = "pack", "src\$project\$project.csproj", "-c", $Configuration, "-o", $outputDirectory, "--no-build"
if ($packageSuffix -ne "0")
{
$cmd += "--version-suffix", "-$packageSuffix"
}
}
else
{
$cmd = "build", "-c", $Configuration, "src\$project\$project.csproj", "-v", "m"
}
Write-Host dotnet $cmd
& { dotnet $cmd }
}