From 659e6ed29204917a1f61c3ae29c9aee249f0aafe Mon Sep 17 00:00:00 2001 From: Chris Richards Date: Wed, 14 Dec 2016 18:17:57 +0000 Subject: [PATCH] Adds Build.ps1 and appveyor.yml --- .gitignore | 2 ++ Build.ps1 | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++ appveyor.yml | 29 ++++++++++++++++++++++++ project.json | 11 +++++----- 4 files changed, 98 insertions(+), 6 deletions(-) create mode 100644 Build.ps1 create mode 100644 appveyor.yml diff --git a/.gitignore b/.gitignore index 0ca27f0..4ad9e9d 100644 --- a/.gitignore +++ b/.gitignore @@ -232,3 +232,5 @@ _Pvt_Extensions # FAKE - F# Make .fake/ + +.artifacts/ \ No newline at end of file diff --git a/Build.ps1 b/Build.ps1 new file mode 100644 index 0000000..aad03b4 --- /dev/null +++ b/Build.ps1 @@ -0,0 +1,62 @@ +<# +.SYNOPSIS + You can add this to you build script to ensure that psbuild is available before calling + Invoke-MSBuild. If psbuild is not available locally it will be downloaded automatically. +#> +function EnsurePsbuildInstalled{ + [cmdletbinding()] + param( + [string]$psbuildInstallUri = 'https://raw.githubusercontent.com/ligershark/psbuild/master/src/GetPSBuild.ps1' + ) + process{ + if(-not (Get-Command "Invoke-MsBuild" -errorAction SilentlyContinue)){ + 'Installing psbuild from [{0}]' -f $psbuildInstallUri | Write-Verbose + (new-object Net.WebClient).DownloadString($psbuildInstallUri) | iex + } + else{ + 'psbuild already loaded, skipping download' | Write-Verbose + } + + # make sure it's loaded and throw if not + if(-not (Get-Command "Invoke-MsBuild" -errorAction SilentlyContinue)){ + throw ('Unable to install/load psbuild from [{0}]' -f $psbuildInstallUri) + } + } +} + +# Taken from psake https://github.com/psake/psake + +<# +.SYNOPSIS + This is a helper function that runs a scriptblock and checks the PS variable $lastexitcode + to see if an error occcured. If an error is detected then an exception is thrown. + This function allows you to run command-line programs without having to + explicitly check the $lastexitcode variable. +.EXAMPLE + exec { svn info $repository_trunk } "Error executing SVN. Please verify SVN command-line client is installed" +#> +function Exec +{ + [CmdletBinding()] + param( + [Parameter(Position=0,Mandatory=1)][scriptblock]$cmd, + [Parameter(Position=1,Mandatory=0)][string]$errorMessage = ($msgs.error_bad_command -f $cmd) + ) + & $cmd + if ($lastexitcode -ne 0) { + throw ("Exec: " + $errorMessage) + } +} + +if(Test-Path .\artifacts) { Remove-Item .\artifacts -Force -Recurse } + +EnsurePsbuildInstalled + +exec { & dotnet restore } + +$revision = @{ $true = $env:APPVEYOR_BUILD_NUMBER; $false = 1 }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL]; +$revision = "{0:D}" -f [convert]::ToInt32($revision, 10) + +exec { & dotnet publish -c Release -r win10-x64 -o .\artifacts/win10-x64 --version-suffix=$revision } +exec { & dotnet publish -c Release -r osx.10.10-x64 -o .\artifacts/osx.10.10-x64 --version-suffix=$revision } +exec { & dotnet publish -c Release -r ubuntu.14.04-x64 -o .\artifacts/ubuntu.14.04-x64 --version-suffix=$revision } diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..fa9d0c8 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,29 @@ +version: '{build}' +pull_requests: + do_not_increment_build_number: true +branches: + only: + - master +nuget: + disable_publish_on_pr: true +build_script: +- ps: .\Build.ps1 +test: off +artifacts: +- path: .\artifacts\win10-x64 + name: dbf-win10-x64 +- path: .\artifacts\osx.10.10-x64 + name: dbf-osx.10.10-x64 +- path: .\artifacts\ubuntu.14.04-x64 + name: dbf-ubuntu.14.04-x64 +deploy: + description: 'Release description' + provider: GitHub + auth_token: + secure: zIuIoM6+3Bc95kSVegG4Lwls01vu+J5OlwOFG2CSaB2YLNdYsTtNqJVnWrnIXMBl + artifact: artifacts\dbf-win10-x64.zip,artifacts\dbf-osx.10.10-x64.zip,artifacts\dbf-ubuntu.14.04-x64.zip + draft: false + prerelease: false + on: + branch: master + appveyor_repo_tag: true \ No newline at end of file diff --git a/project.json b/project.json index e8aa699..8dec169 100644 --- a/project.json +++ b/project.json @@ -19,7 +19,6 @@ "dependencies": { "Microsoft.NETCore.App": { - "type": "platform", "version": "1.1.0" }, "CommandLineParser": "2.1.1-beta", @@ -34,9 +33,9 @@ "tooling": { "defaultNamespace": "Dbf" }, - // "runtimes": { - // "win10-x64": {}, - // "osx.10.10-x64": {}, - // "ubuntu.14.04-x64": {} - // } + "runtimes": { + "win10-x64": {}, + "osx.10.10-x64": {}, + "ubuntu.14.04-x64": {} + } }