|
1 | | -param( |
2 | | - [String] $majorMinor = "0.0", # 2.0 |
3 | | - [String] $patch = "0", # $env:APPVEYOR_BUILD_VERSION |
4 | | - [String] $customLogger = "", # C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll |
5 | | - [Switch] $notouch, |
6 | | - [String] $sln # e.g serilog-sink-name |
7 | | -) |
| 1 | +Push-Location $PSScriptRoot |
8 | 2 |
|
9 | | -function Set-AssemblyVersions($informational, $assembly) |
10 | | -{ |
11 | | - (Get-Content assets/CommonAssemblyInfo.cs) | |
12 | | - ForEach-Object { $_ -replace """1.0.0.0""", """$assembly""" } | |
13 | | - ForEach-Object { $_ -replace """1.0.0""", """$informational""" } | |
14 | | - ForEach-Object { $_ -replace """1.1.1.1""", """$($informational).0""" } | |
15 | | - Set-Content assets/CommonAssemblyInfo.cs |
16 | | -} |
17 | | - |
18 | | -function Install-NuGetPackages($solution) |
19 | | -{ |
20 | | - nuget restore $solution |
21 | | -} |
22 | | - |
23 | | -function Invoke-MSBuild($solution, $customLogger) |
24 | | -{ |
25 | | - if ($customLogger) |
26 | | - { |
27 | | - msbuild "$solution" /verbosity:minimal /p:Configuration=Release /logger:"$customLogger" |
28 | | - } |
29 | | - else |
30 | | - { |
31 | | - msbuild "$solution" /verbosity:minimal /p:Configuration=Release |
32 | | - } |
33 | | -} |
34 | | - |
35 | | -function Invoke-NuGetPackProj($csproj) |
36 | | -{ |
37 | | - nuget pack -Prop Configuration=Release -Symbols $csproj |
38 | | -} |
39 | | - |
40 | | -function Invoke-NuGetPackSpec($nuspec, $version) |
41 | | -{ |
42 | | - nuget pack $nuspec -Version $version -OutputDirectory ..\..\ |
43 | | -} |
44 | | - |
45 | | -function Invoke-NuGetPack($version) |
46 | | -{ |
47 | | - ls src/**/*.csproj | |
48 | | - Where-Object { -not ($_.Name -like "*net40*") } | |
49 | | - ForEach-Object { Invoke-NuGetPackProj $_ } |
50 | | -} |
51 | | - |
52 | | -function Invoke-Build($majorMinor, $patch, $customLogger, $notouch, $sln) |
53 | | -{ |
54 | | - $package="$majorMinor.$patch" |
55 | | - $slnfile = "$sln.sln" |
| 3 | +if(Test-Path .\artifacts) { Remove-Item .\artifacts -Force -Recurse } |
56 | 4 |
|
57 | | - Write-Output "$sln $package" |
| 5 | +& dotnet restore --no-cache |
58 | 6 |
|
59 | | - if (-not $notouch) |
60 | | - { |
61 | | - $assembly = "$majorMinor.0.0" |
| 7 | +$branch = $(git symbolic-ref --short -q HEAD) |
| 8 | +$revision = @{ $true = $env:APPVEYOR_BUILD_NUMBER; $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL]; |
| 9 | +$suffix = @{ $true = ""; $false = "$branch-$revision"}[$branch -eq "master" -and $revision -ne "local"] |
62 | 10 |
|
63 | | - Write-Output "Assembly version will be set to $assembly" |
64 | | - Set-AssemblyVersions $package $assembly |
65 | | - } |
| 11 | +foreach ($src in ls src/Serilog.*) { |
| 12 | + Push-Location $src |
66 | 13 |
|
67 | | - Install-NuGetPackages $slnfile |
68 | | - |
69 | | - Invoke-MSBuild $slnfile $customLogger |
| 14 | + & dotnet pack -c Release -o ..\..\.\artifacts --version-suffix=$suffix |
| 15 | + if($LASTEXITCODE -ne 0) { exit 1 } |
70 | 16 |
|
71 | | - Invoke-NuGetPack $package |
| 17 | + Pop-Location |
72 | 18 | } |
73 | 19 |
|
74 | | -$ErrorActionPreference = "Stop" |
| 20 | +foreach ($test in ls test/Serilog.*.Tests) { |
| 21 | + Push-Location $test |
75 | 22 |
|
76 | | -if (-not $sln) |
77 | | -{ |
78 | | - $slnfull = ls *.sln | |
79 | | - Where-Object { -not ($_.Name -like "*net40*") } | |
80 | | - Select -first 1 |
| 23 | + & dotnet test -c Release |
| 24 | + if($LASTEXITCODE -ne 0) { exit 2 } |
81 | 25 |
|
82 | | - $sln = $slnfull.BaseName |
| 26 | + Pop-Location |
83 | 27 | } |
84 | 28 |
|
85 | | -Invoke-Build $majorMinor $patch $customLogger $notouch $sln |
| 29 | +Pop-Location |
0 commit comments