From 47fc3041c2d7c0487b88c554e3ff9a0b85cf4488 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Wed, 12 Sep 2018 17:42:01 +1200 Subject: [PATCH] Update Azure Pipelines build (#1822) --- azure-pipelines.yml | 60 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 12 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 3b9370d1..0dc06164 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,16 +1,52 @@ -# Starter pipeline -# Start with a minimal pipeline that you can customize to build and deploy your code. -# Add steps that build, run tests, deploy, and more: -# https://aka.ms/yaml - pool: - vmImage: 'Ubuntu 16.04' + vmImage: 'VS2017-Win2016' steps: -- script: echo Hello, world! - displayName: 'Run a one-line script' +- powershell: | + $buildNumber = [int]$Env:BUILD_ID + write-host "Build number $buildNumber" -fore white + $basePath = resolve-path . + $keyPath = "$basePath\key.snk" + $sign = $false + if ($Env:KEY_DATA) + { + $keyData = [System.Convert]::FromBase64String($Env:KEY_DATA) + [System.IO.File]::WriteAllBytes($keyPath, $keyData) + $sign = $true + } + write-host "Sign assemblies $sign" -fore white + $formattedBuildNumber = $buildNumber.ToString("D6") + $nugetPrerelease = "build$formattedBuildNumber" + .\Build\runbuild.ps1 -properties @{"signAssemblies"=$sign; "signKeyPath"=$keyPath; "treatWarningsAsErrors"=$true; "nugetPrerelease"=$nugetPrerelease;} + env: + KEY_DATA: $(newtonsoft.keyData) + BUILD_ID: $(Build.BuildId) + displayName: 'Run build' -- script: | - echo Add other tasks to build, test, and deploy your project. - echo See https://aka.ms/yaml - displayName: 'Run a multi-line script' +- task: PublishTestResults@2 + inputs: + testRunner: 'NUnit' + testResultsFiles: '**/Working/*.xml' + displayName: 'Publish NUnit test results' + +- task: PublishTestResults@2 + inputs: + testRunner: 'VSTest' + testResultsFiles: '**/Working/*.trx' + displayName: 'Publish XUnit test results' + +- powershell: | + $branch = [string]$Env:BRANCH_NAME + write-host "Branch $branch" -fore Green + if ($branch -eq "master" -and (Test-Path -path ".\Working\NuGet")) + { + $apiKey = $Env:MYGET_KEY + $mainPkg = (get-childitem .\Working\NuGet | Where {$_.Extension -eq ".nupkg" -and !$_.Name.Contains(".symbols.") } | select -first 1).FullName + write-host + write-host "Pushing package $mainPkg to myget" -fore Green + .\Build\Temp\nuget.exe push $mainPkg $apiKey -Source https://www.myget.org/F/json-net/api/v2/package + } + env: + MYGET_KEY: $(newtonsoft.mygetKey) + BRANCH_NAME: $(Build.SourceBranchName) + displayName: 'Publish NuGet package'