Update Azure Pipelines build (#1822)

This commit is contained in:
James Newton-King
2018-09-12 17:42:01 +12:00
committed by GitHub
parent 18fef752f3
commit 47fc3041c2
+48 -12
View File
@@ -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'