forked from BedeGaming/sinks-rollingfile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ps1
65 lines (56 loc) · 1.71 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
param(
[parameter(Position=0)][string] $PreReleaseSuffix = ''
)
$autoGeneratedVersion = $false
Write-Host "Current build: $env:build_number"
# Generate version number if not set
if ($env:build_number -eq $null) {
$autoVersion = [math]::floor((New-TimeSpan $(Get-Date) $(Get-Date -month 1 -day 1 -year 2016 -hour 0 -minute 0 -second 0)).TotalMinutes * -1).ToString() + "-" + (Get-Date).ToString("ss")
$env:build_number = "rc1-" + $autoVersion
$autoGeneratedVersion = $true
Write-Host "Set version to $autoVersion"
}
ls */*/project.json | foreach { echo $_.FullName} |
foreach {
$content = get-content "$_"
$content = $content.Replace("2.0.0-*", "2.0.0-$env:build_number")
set-content "$_" $content -encoding UTF8
}
# Restore packages and build product
& dotnet restore # Restore all packages
if ($LASTEXITCODE -ne 0)
{
throw "dotnet restore failed with exit code $LASTEXITCODE"
}
# Build all
dir "src/*" | where {$_.PsIsContainer} |
foreach {
if ($PreReleaseSuffix) {
& dotnet build "$_" --version-suffix "$PreReleaseSuffix"
} else {
& dotnet build "$_"
}
}
# Run tests
dir "test/*" | where {$_.PsIsContainer} |
foreach {
& dotnet test "$_"
}
# Package all
dir "src/*" | where {$_.PsIsContainer} |
foreach {
if ($PreReleaseSuffix) {
& dotnet pack "$_" -c Release -o .\.nupkg\ --version-suffix "$PreReleaseSuffix"
} else {
& dotnet pack "$_" -c Release -o .\.nupkg\
}
}
ls */*/project.json | foreach { echo $_.FullName} |
foreach {
$content = get-content "$_"
$content = $content.Replace("2.0.0-$env:build_number", "2.0.0-*")
set-content "$_" $content -encoding UTF8
}
if ($autoGeneratedVersion){
$env:build_number = $null
}