Skip to content

Commit

Permalink
Add appveyor yaml and update build script
Browse files Browse the repository at this point in the history
- added appveyor.yml from the file sink project
- replaced the Build.ps1 contents with the build script from file sink project
  • Loading branch information
sirkirby authored Dec 5, 2017
1 parent e725973 commit 807ab50
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 68 deletions.
99 changes: 31 additions & 68 deletions Build.ps1
Original file line number Diff line number Diff line change
@@ -1,85 +1,48 @@
param(
[String] $majorMinor = "0.0", # 2.0
[String] $patch = "0", # $env:APPVEYOR_BUILD_VERSION
[String] $customLogger = "", # C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll
[Switch] $notouch,
[String] $sln # e.g serilog-sink-name
)
echo "build: Build started"

function Set-AssemblyVersions($informational, $assembly)
{
(Get-Content assets/CommonAssemblyInfo.cs) |
ForEach-Object { $_ -replace """1.0.0.0""", """$assembly""" } |
ForEach-Object { $_ -replace """1.0.0""", """$informational""" } |
ForEach-Object { $_ -replace """1.1.1.1""", """$($informational).0""" } |
Set-Content assets/CommonAssemblyInfo.cs
}
Push-Location $PSScriptRoot

function Install-NuGetPackages($solution)
{
nuget restore $solution
if(Test-Path .\artifacts) {
echo "build: Cleaning .\artifacts"
Remove-Item .\artifacts -Force -Recurse
}

function Invoke-MSBuild($solution, $customLogger)
{
if ($customLogger)
{
msbuild "$solution" /verbosity:minimal /p:Configuration=Release /logger:"$customLogger"
}
else
{
msbuild "$solution" /verbosity:minimal /p:Configuration=Release
}
}
& dotnet restore --no-cache

function Invoke-NuGetPackProj($csproj)
{
nuget pack -Prop Configuration=Release -Symbols $csproj
}
$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL];
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "master" -and $revision -ne "local"]
$commitHash = $(git rev-parse --short HEAD)
$buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""]

function Invoke-NuGetPackSpec($nuspec, $version)
{
nuget pack $nuspec -Version $version -OutputDirectory ..\..\
}
echo "build: Package version suffix is $suffix"
echo "build: Build version suffix is $buildSuffix"

function Invoke-NuGetPack($version)
{
ls src/**/*.csproj |
Where-Object { -not ($_.Name -like "*net40*") } |
ForEach-Object { Invoke-NuGetPackProj $_ }
}

function Invoke-Build($majorMinor, $patch, $customLogger, $notouch, $sln)
{
$package="$majorMinor.$patch"
$slnfile = "$sln.sln"

Write-Output "$sln $package"
foreach ($src in ls src/*) {
Push-Location $src

if (-not $notouch)
{
$assembly = "$majorMinor.0.0"
echo "build: Packaging project in $src"

Write-Output "Assembly version will be set to $assembly"
Set-AssemblyVersions $package $assembly
& dotnet build -c Release --version-suffix=$buildSuffix
if ($suffix) {
& dotnet pack -c Release --include-source -o ..\..\artifacts --version-suffix=$suffix --no-build
} else {
& dotnet pack -c Release --include-source -o ..\..\artifacts --no-build
}
if($LASTEXITCODE -ne 0) { exit 1 }

Install-NuGetPackages $slnfile

Invoke-MSBuild $slnfile $customLogger

Invoke-NuGetPack $package
Pop-Location
}

$ErrorActionPreference = "Stop"
foreach ($test in ls test/*.Tests) {
Push-Location $test

echo "build: Testing project in $test"

if (-not $sln)
{
$slnfull = ls *.sln |
Where-Object { -not ($_.Name -like "*net40*") } |
Select -first 1
& dotnet test -c Release
if($LASTEXITCODE -ne 0) { exit 3 }

$sln = $slnfull.BaseName
Pop-Location
}

Invoke-Build $majorMinor $patch $customLogger $notouch $sln
Pop-Location
25 changes: 25 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: '{build}'
skip_tags: true
image: Visual Studio 2017
configuration: Release
install:
- ps: mkdir -Force ".\build\" | Out-Null
build_script:
- ps: ./Build.ps1
test: off
artifacts:
- path: artifacts/Serilog.*.nupkg
deploy:
- provider: NuGet
api_key:
secure: nvZ/z+pMS91b3kG4DgfES5AcmwwGoBYQxr9kp4XiJHj25SAlgdIxFx++1N0lFH2x
skip_symbols: true
on:
branch: /^(master|dev)$/
- provider: GitHub
auth_token:
secure: p4LpVhBKxGS5WqucHxFQ5c7C8cP74kbNB0Z8k9Oxx/PMaDQ1+ibmoexNqVU5ZlmX
artifact: /Serilog.*\.nupkg/
tag: v$(appveyor_build_version)
on:
branch: master
Empty file added test/.gitkeep
Empty file.

0 comments on commit 807ab50

Please sign in to comment.