forked from rflechner/ScrapySharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
58 lines (53 loc) · 1.74 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
# functions coming from https://blogs.msdn.microsoft.com/jaredpar/2009/01/16/powershell-linq-take-count-and-take-while/
#============================================================================
# Take count elements fro the pipeline
#============================================================================
function Take-Count() {
param ( [int]$count = $(throw "Need a count") )
begin {
$total = 0;
}
process {
if ( $total -lt $count ) {
$_
}
$total += 1
}
}
#============================================================================
# Take elements from the pipeline while the predicate is true
#============================================================================
function Take-While() {
param ( [scriptblock]$pred = $(throw "Need a predicate") )
begin {
$take = $true
}
process {
if ( $take ) {
$take = & $pred $_
if ( $take ) {
$_
}
}
}
}
$lines = Get-Content .\ReleaseNotes.md | Where-Object { $_.Length -gt 0 }
$top = $lines | Select-Object -First 1
$version = $top.Replace("#", "").Trim()
$releaseNotes = ""
$notes = $lines | Select-Object -Skip 1 | Take-While { -not $_.Trim().StartsWith("#") }
foreach ($note in $notes) {
$releaseNotes += $note + "`n"
}
dotnet restore
dotnet test ScrapySharp.Tests\ScrapySharp.Tests.csproj
dotnet build --configuration release
dotnet pack --configuration release /p:PackageVersion=$version /p:PackageReleaseNotes=$releaseNotes
if (Test-Path .\release)
{
Remove-Item -Recurse -Force -Path release
}
mkdir release
xcopy .\ScrapySharp\bin\Release\*.nupkg release
Remove-Item .\ScrapySharp\bin\**\*.nupkg
Remove-Item .\ScrapySharp.Core\bin\**\*.nupkg