-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add appveyor yaml and update build script
- added appveyor.yml from the file sink project - replaced the Build.ps1 contents with the build script from file sink project
- Loading branch information
Showing
3 changed files
with
56 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.