2016-08-30 04:12:01 +08:00
|
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
$repoRoot = Join-Path $PSScriptRoot '..'
|
2016-10-11 06:24:04 +08:00
|
|
|
$script:administratorsGroupSID = "S-1-5-32-544"
|
|
|
|
$script:usersGroupSID = "S-1-5-32-545"
|
2016-08-30 04:12:01 +08:00
|
|
|
|
|
|
|
Import-Module (Join-Path $repoRoot 'build.psm1')
|
|
|
|
|
2016-10-11 06:24:04 +08:00
|
|
|
function New-LocalUser
|
|
|
|
{
|
|
|
|
<#
|
|
|
|
.SYNOPSIS
|
|
|
|
Creates a local user with the specified username and password
|
|
|
|
.DESCRIPTION
|
|
|
|
.EXAMPLE
|
|
|
|
.PARAMETER
|
|
|
|
username Username of the user which will be created
|
|
|
|
.PARAMETER
|
|
|
|
password Password of the user which will be created
|
|
|
|
.OUTPUTS
|
|
|
|
.NOTES
|
|
|
|
#>
|
|
|
|
param(
|
|
|
|
[Parameter(Mandatory=$true)]
|
|
|
|
[string] $username,
|
|
|
|
|
|
|
|
[Parameter(Mandatory=$true)]
|
|
|
|
[string] $password
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
$LocalComputer = [ADSI] "WinNT://$env:computername";
|
|
|
|
$user = $LocalComputer.Create('user', $username);
|
|
|
|
$user.SetPassword($password) | out-null;
|
|
|
|
$user.SetInfo() | out-null;
|
|
|
|
}
|
|
|
|
|
|
|
|
<#
|
|
|
|
Converts SID to NT Account Name
|
|
|
|
#>
|
|
|
|
function ConvertTo-NtAccount
|
|
|
|
{
|
|
|
|
param(
|
|
|
|
[Parameter(Mandatory=$true)]
|
|
|
|
[string] $sid
|
|
|
|
)
|
|
|
|
(new-object System.Security.Principal.SecurityIdentifier($sid)).translate([System.Security.Principal.NTAccount]).Value
|
|
|
|
}
|
|
|
|
|
|
|
|
<#
|
|
|
|
Add a user to a local security group
|
|
|
|
#>
|
|
|
|
function Add-UserToGroup
|
|
|
|
{
|
|
|
|
param(
|
|
|
|
[Parameter(Mandatory=$true)]
|
|
|
|
[string] $username,
|
|
|
|
|
|
|
|
[Parameter(Mandatory=$true, ParameterSetName = "SID")]
|
|
|
|
[string] $groupSid,
|
|
|
|
|
|
|
|
[Parameter(Mandatory=$true, ParameterSetName = "Name")]
|
|
|
|
[string] $group
|
|
|
|
)
|
|
|
|
|
|
|
|
$userAD = [ADSI] "WinNT://$env:computername/${username},user"
|
|
|
|
|
|
|
|
if($PsCmdlet.ParameterSetName -eq "SID")
|
|
|
|
{
|
|
|
|
$ntAccount=ConvertTo-NtAccount $groupSid
|
|
|
|
$group =$ntAccount.Split("\\")[1]
|
|
|
|
}
|
|
|
|
|
|
|
|
$groupAD = [ADSI] "WinNT://$env:computername/${group},group"
|
|
|
|
|
|
|
|
$groupAD.Add($userAD.AdsPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-09-01 04:02:12 +08:00
|
|
|
# tests if we should run a daily build
|
|
|
|
# returns true if the build is scheduled
|
|
|
|
# or is a pushed tag
|
|
|
|
Function Test-DailyBuild
|
|
|
|
{
|
2016-09-30 07:26:34 +08:00
|
|
|
if(($env:PS_DAILY_BUILD -eq 'True') -or ($env:APPVEYOR_SCHEDULED_BUILD -eq 'True') -or ($env:APPVEYOR_REPO_TAG_NAME))
|
2016-09-01 04:02:12 +08:00
|
|
|
{
|
|
|
|
return $true
|
|
|
|
}
|
2016-09-30 07:26:34 +08:00
|
|
|
|
2016-09-01 04:02:12 +08:00
|
|
|
return $false
|
|
|
|
}
|
|
|
|
|
|
|
|
# Sets a build variable
|
|
|
|
Function Set-BuildVariable
|
|
|
|
{
|
|
|
|
param(
|
|
|
|
[Parameter(Mandatory=$true)]
|
|
|
|
[string]
|
|
|
|
$Name,
|
|
|
|
|
|
|
|
[Parameter(Mandatory=$true)]
|
|
|
|
[string]
|
|
|
|
$Value
|
|
|
|
)
|
|
|
|
|
|
|
|
if($env:AppVeyor)
|
|
|
|
{
|
|
|
|
Set-AppveyorBuildVariable @PSBoundParameters
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Set-Item env:/$name -Value $Value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-30 05:21:48 +08:00
|
|
|
# Emulates running all of AppVeyor but locally
|
|
|
|
# should not be used on AppVeyor
|
2016-08-30 04:12:01 +08:00
|
|
|
function Invoke-AppVeyorFull
|
|
|
|
{
|
2016-09-01 04:02:12 +08:00
|
|
|
param(
|
|
|
|
[switch] $APPVEYOR_SCHEDULED_BUILD,
|
|
|
|
[switch] $CleanRepo
|
|
|
|
)
|
|
|
|
if($CleanRepo)
|
|
|
|
{
|
|
|
|
Clear-PSRepo
|
|
|
|
}
|
|
|
|
|
|
|
|
if($env:APPVEYOR)
|
|
|
|
{
|
|
|
|
throw "This function is to simulate appveyor, but not to be run from appveyor!"
|
|
|
|
}
|
|
|
|
|
|
|
|
if($APPVEYOR_SCHEDULED_BUILD)
|
|
|
|
{
|
|
|
|
$env:APPVEYOR_SCHEDULED_BUILD = 'True'
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
Invoke-AppVeyorInstall
|
|
|
|
Invoke-AppVeyorBuild
|
|
|
|
Invoke-AppVeyorTest -ErrorAction Continue
|
|
|
|
Invoke-AppveyorFinish
|
|
|
|
}
|
|
|
|
finally {
|
|
|
|
if($APPVEYOR_SCHEDULED_BUILD -and $env:APPVEYOR_SCHEDULED_BUILD)
|
|
|
|
{
|
|
|
|
Remove-Item env:APPVEYOR_SCHEDULED_BUILD
|
|
|
|
}
|
|
|
|
}
|
2016-08-30 04:12:01 +08:00
|
|
|
}
|
|
|
|
|
2016-08-30 05:21:48 +08:00
|
|
|
# Implements the AppVeyor 'build_script' step
|
2016-08-30 04:12:01 +08:00
|
|
|
function Invoke-AppVeyorBuild
|
|
|
|
{
|
|
|
|
# check to be sure our test tags are correct
|
|
|
|
$result = Get-PesterTag
|
|
|
|
if ( $result.Result -ne "Pass" ) {
|
|
|
|
$result.Warnings
|
|
|
|
throw "Tags must be CI, Feature, Scenario, or Slow"
|
|
|
|
}
|
2016-11-12 03:12:07 +08:00
|
|
|
|
|
|
|
if(Test-DailyBuild)
|
|
|
|
{
|
2016-11-29 09:57:04 +08:00
|
|
|
Start-PSBuild -Configuration 'CodeCoverage' -PSModuleRestore -Publish
|
2016-11-12 03:12:07 +08:00
|
|
|
}
|
|
|
|
|
2016-11-19 01:55:23 +08:00
|
|
|
Start-PSBuild -FullCLR -PSModuleRestore
|
2016-11-24 04:54:52 +08:00
|
|
|
Start-PSBuild -CrossGen -PSModuleRestore -Configuration 'Release'
|
2016-08-30 04:12:01 +08:00
|
|
|
}
|
|
|
|
|
2016-08-30 05:21:48 +08:00
|
|
|
# Implements the AppVeyor 'install' step
|
2016-08-30 04:12:01 +08:00
|
|
|
function Invoke-AppVeyorInstall
|
|
|
|
{
|
2016-09-01 04:02:12 +08:00
|
|
|
if(Test-DailyBuild){
|
|
|
|
$buildName = "[Daily]"
|
|
|
|
if($env:APPVEYOR_PULL_REQUEST_TITLE)
|
|
|
|
{
|
|
|
|
$buildName += $env:APPVEYOR_PULL_REQUEST_TITLE
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$buildName += $env:APPVEYOR_REPO_COMMIT_MESSAGE
|
|
|
|
}
|
|
|
|
|
|
|
|
Update-AppveyorBuild -message $buildName
|
|
|
|
}
|
|
|
|
|
2016-10-11 06:24:04 +08:00
|
|
|
if ($env:APPVEYOR)
|
|
|
|
{
|
|
|
|
#
|
|
|
|
# Generate new credential for appveyor (only) remoting tests.
|
|
|
|
#
|
|
|
|
Write-Verbose "Creating account for remoting tests in AppVeyor."
|
|
|
|
|
|
|
|
# Password
|
|
|
|
$randomObj = [System.Random]::new()
|
|
|
|
$password = ""
|
|
|
|
1..(Get-Random -Minimum 15 -Maximum 126) | ForEach { $password = $password + [char]$randomObj.next(45,126) }
|
|
|
|
|
|
|
|
# Account
|
|
|
|
$userName = 'appVeyorRemote'
|
|
|
|
New-LocalUser -username $userName -password $password
|
|
|
|
Add-UserToGroup -username $userName -groupSid $script:administratorsGroupSID
|
|
|
|
|
|
|
|
# Provide credentials globally for remote tests.
|
|
|
|
$ss = ConvertTo-SecureString -String $password -AsPlainText -Force
|
|
|
|
$appveyorRemoteCredential = [PSCredential]::new("$env:COMPUTERNAME\$userName", $ss)
|
|
|
|
$appveyorRemoteCredential | Export-Clixml -Path "$env:TEMP\AppVeyorRemoteCred.xml" -Force
|
|
|
|
|
|
|
|
# Check that LocalAccountTokenFilterPolicy policy is set, since it is needed for remoting
|
|
|
|
# using above local admin account.
|
|
|
|
Write-Verbose "Checking for LocalAccountTokenFilterPolicy in AppVeyor."
|
|
|
|
$haveLocalAccountTokenFilterPolicy = $false
|
|
|
|
try
|
|
|
|
{
|
|
|
|
$haveLocalAccountTokenFilterPolicy = ((Get-ItemPropertyValue -Path HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name LocalAccountTokenFilterPolicy) -eq 1)
|
|
|
|
}
|
|
|
|
catch { }
|
|
|
|
if (!$haveLocalAccountTokenFilterPolicy)
|
|
|
|
{
|
|
|
|
Write-Verbose "Setting the LocalAccountTokenFilterPolicy for remoting tests"
|
|
|
|
Set-ItemProperty -Path HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name LocalAccountTokenFilterPolicy -Value 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-01 04:02:12 +08:00
|
|
|
Set-BuildVariable -Name TestPassed -Value False
|
2016-08-30 04:12:01 +08:00
|
|
|
Start-PSBootstrap -Force
|
|
|
|
}
|
|
|
|
|
2016-08-30 05:21:48 +08:00
|
|
|
# A wrapper to ensure that we upload test results
|
|
|
|
# and that if we are not able to that it does not fail
|
|
|
|
# the CI build
|
2016-08-30 04:12:01 +08:00
|
|
|
function Update-AppVeyorTestResults
|
|
|
|
{
|
|
|
|
param(
|
|
|
|
[string] $resultsFile
|
|
|
|
)
|
|
|
|
|
|
|
|
if($env:Appveyor)
|
|
|
|
{
|
2016-08-30 04:57:20 +08:00
|
|
|
$retryCount = 0
|
|
|
|
$pushedResults = $false
|
|
|
|
$pushedArtifacts = $false
|
|
|
|
while( (!$pushedResults -or !$pushedResults) -and $retryCount -lt 3)
|
|
|
|
{
|
|
|
|
if($retryCount -gt 0)
|
|
|
|
{
|
|
|
|
Write-Verbose "Retrying updating test artifacts..."
|
|
|
|
}
|
|
|
|
|
|
|
|
$retryCount++
|
|
|
|
$resolvedResultsPath = (Resolve-Path $resultsFile)
|
|
|
|
try {
|
|
|
|
(New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", $resolvedResultsPath)
|
|
|
|
$pushedResults = $true
|
|
|
|
}
|
|
|
|
catch {
|
|
|
|
Write-Warning "Pushing test result failed..."
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
Push-AppveyorArtifact $resolvedResultsPath
|
|
|
|
$pushedArtifacts = $true
|
|
|
|
}
|
|
|
|
catch {
|
|
|
|
Write-Warning "Pushing test Artifact failed..."
|
|
|
|
}
|
|
|
|
}
|
2016-08-30 05:21:48 +08:00
|
|
|
|
2016-08-30 04:57:20 +08:00
|
|
|
if(!$pushedResults -or !$pushedResults)
|
|
|
|
{
|
|
|
|
Write-Warning "Failed to push all artifacts for $resultsFile"
|
|
|
|
}
|
2016-08-30 04:12:01 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Write-Warning "Not running in appveyor, skipping upload of test results: $resultsFile"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-30 05:21:48 +08:00
|
|
|
# Implement AppVeyor 'Test_script'
|
2016-08-30 04:12:01 +08:00
|
|
|
function Invoke-AppVeyorTest
|
|
|
|
{
|
2016-08-31 02:47:27 +08:00
|
|
|
[CmdletBinding()]
|
|
|
|
param()
|
2016-08-30 04:12:01 +08:00
|
|
|
#
|
|
|
|
# CoreCLR
|
2016-09-01 04:02:12 +08:00
|
|
|
|
2016-11-24 04:54:52 +08:00
|
|
|
$env:CoreOutput = Split-Path -Parent (Get-PSOutput -Options (New-PSOptions -Publish -Configuration 'Release'))
|
2016-08-30 04:12:01 +08:00
|
|
|
Write-Host -Foreground Green 'Run CoreCLR tests'
|
2016-09-16 10:33:54 +08:00
|
|
|
$testResultsNonAdminFile = "$pwd\TestsResultsNonAdmin.xml"
|
|
|
|
$testResultsAdminFile = "$pwd\TestsResultsAdmin.xml"
|
|
|
|
$testResultsFileFullCLR = "$pwd\TestsResults.FullCLR.xml"
|
2016-08-30 04:12:01 +08:00
|
|
|
if(!(Test-Path "$env:CoreOutput\powershell.exe"))
|
|
|
|
{
|
2016-08-30 05:52:50 +08:00
|
|
|
throw "CoreCLR PowerShell.exe was not built"
|
2016-08-30 04:12:01 +08:00
|
|
|
}
|
|
|
|
|
2016-09-16 10:33:54 +08:00
|
|
|
if(-not (Test-DailyBuild))
|
2016-09-01 04:02:12 +08:00
|
|
|
{
|
2016-09-16 10:33:54 +08:00
|
|
|
# Pester doesn't allow Invoke-Pester -TagAll@('CI', 'RequireAdminOnWindows') currently
|
|
|
|
# https://github.com/pester/Pester/issues/608
|
|
|
|
# To work-around it, we exlude all categories, but 'CI' from the list
|
2016-09-27 04:16:32 +08:00
|
|
|
$ExcludeTag = @('Slow', 'Feature', 'Scenario')
|
2016-09-16 10:33:54 +08:00
|
|
|
Write-Host -Foreground Green 'Running "CI" CoreCLR tests..'
|
2016-09-01 04:02:12 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-09-27 04:16:32 +08:00
|
|
|
$ExcludeTag = @()
|
2016-09-16 10:33:54 +08:00
|
|
|
Write-Host -Foreground Green 'Running all CoreCLR tests..'
|
2016-09-01 04:02:12 +08:00
|
|
|
}
|
|
|
|
|
2016-09-27 04:16:32 +08:00
|
|
|
Start-PSPester -bindir $env:CoreOutput -outputFile $testResultsNonAdminFile -Unelevate -Tag @() -ExcludeTag ($ExcludeTag + @('RequireAdminOnWindows'))
|
2016-09-16 10:33:54 +08:00
|
|
|
Write-Host -Foreground Green 'Upload CoreCLR Non-Admin test results'
|
|
|
|
Update-AppVeyorTestResults -resultsFile $testResultsNonAdminFile
|
|
|
|
|
2016-09-27 04:16:32 +08:00
|
|
|
Start-PSPester -bindir $env:CoreOutput -outputFile $testResultsAdminFile -Tag @('RequireAdminOnWindows') -ExcludeTag $ExcludeTag
|
2016-09-16 10:33:54 +08:00
|
|
|
Write-Host -Foreground Green 'Upload CoreCLR Admin test results'
|
|
|
|
Update-AppVeyorTestResults -resultsFile $testResultsAdminFile
|
2016-08-30 04:12:01 +08:00
|
|
|
|
|
|
|
#
|
|
|
|
# FullCLR
|
|
|
|
$env:FullOutput = Split-Path -Parent (Get-PSOutput -Options (New-PSOptions -FullCLR))
|
|
|
|
Write-Host -Foreground Green 'Run FullCLR tests'
|
2016-08-31 02:47:27 +08:00
|
|
|
Start-PSPester -FullCLR -bindir $env:FullOutput -outputFile $testResultsFileFullCLR -Tag $null -path 'test/fullCLR'
|
|
|
|
|
|
|
|
Write-Host -Foreground Green 'Upload FullCLR test results'
|
2016-08-30 04:12:01 +08:00
|
|
|
Update-AppVeyorTestResults -resultsFile $testResultsFileFullCLR
|
2016-11-12 03:12:07 +08:00
|
|
|
|
2016-08-30 04:12:01 +08:00
|
|
|
#
|
|
|
|
# Fail the build, if tests failed
|
2016-09-16 10:33:54 +08:00
|
|
|
@(
|
|
|
|
$testResultsNonAdminFile,
|
|
|
|
$testResultsAdminFile,
|
|
|
|
$testResultsFileFullCLR
|
|
|
|
) | % {
|
|
|
|
Test-PSPesterResults -TestResultsFile $_
|
|
|
|
}
|
2016-08-30 04:12:01 +08:00
|
|
|
|
2016-09-01 04:02:12 +08:00
|
|
|
Set-BuildVariable -Name TestPassed -Value True
|
2016-08-30 04:12:01 +08:00
|
|
|
}
|
|
|
|
|
2016-11-24 04:22:18 +08:00
|
|
|
#Implement AppVeyor 'after_test' phase
|
|
|
|
function Invoke-AppVeyorAfterTest
|
|
|
|
{
|
|
|
|
[CmdletBinding()]
|
|
|
|
param()
|
|
|
|
|
|
|
|
if(Test-DailyBuild)
|
|
|
|
{
|
|
|
|
## Publish code coverage build, tests and OpenCover module to artifacts, so webhook has the information.
|
|
|
|
## Build webhook is called after 'after_test' phase, hence we need to do this here and not in AppveyorFinish.
|
|
|
|
$codeCoverageOutput = Split-Path -Parent (Get-PSOutput -Options (New-PSOptions -Configuration CodeCoverage))
|
|
|
|
$codeCoverageArtifacts = Compress-CoverageArtifacts -CodeCoverageOutput $codeCoverageOutput
|
|
|
|
|
|
|
|
Write-Host -ForegroundColor Green 'Upload CodeCoverage artifacts'
|
|
|
|
$codeCoverageArtifacts | % { Push-AppveyorArtifact $_ }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function Compress-CoverageArtifacts
|
|
|
|
{
|
|
|
|
param([string] $CodeCoverageOutput)
|
|
|
|
|
|
|
|
# Create archive for test content, OpenCover module and CodeCoverage build
|
|
|
|
$artifacts = New-Object System.Collections.ArrayList
|
|
|
|
|
|
|
|
$zipTestContentPath = Join-Path $pwd 'tests.zip'
|
|
|
|
Compress-TestContent -Destination $zipTestContentPath
|
2016-11-24 08:38:50 +08:00
|
|
|
$null = $artifacts.Add($zipTestContentPath)
|
2016-11-24 04:22:18 +08:00
|
|
|
|
|
|
|
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
|
|
|
$resolvedPath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath((Join-Path $PSScriptRoot '..\test\tools\OpenCover'))
|
|
|
|
$zipOpenCoverPath = Join-Path $pwd 'OpenCover.zip'
|
|
|
|
[System.IO.Compression.ZipFile]::CreateFromDirectory($resolvedPath, $zipOpenCoverPath)
|
2016-11-24 08:38:50 +08:00
|
|
|
$null = $artifacts.Add($zipOpenCoverPath)
|
2016-11-24 04:22:18 +08:00
|
|
|
|
2016-12-16 02:35:55 +08:00
|
|
|
$zipCodeCoveragePath = Join-Path $pwd "CodeCoverage.zip"
|
2016-11-24 04:22:18 +08:00
|
|
|
Write-Verbose "Zipping ${CodeCoverageOutput} into $zipCodeCoveragePath" -verbose
|
|
|
|
[System.IO.Compression.ZipFile]::CreateFromDirectory($CodeCoverageOutput, $zipCodeCoveragePath)
|
2016-11-24 08:38:50 +08:00
|
|
|
$null = $artifacts.Add($zipCodeCoveragePath)
|
2016-11-24 04:22:18 +08:00
|
|
|
|
|
|
|
return $artifacts
|
|
|
|
}
|
|
|
|
|
2016-11-29 09:57:04 +08:00
|
|
|
function Get-PackageName
|
|
|
|
{
|
|
|
|
$name = git describe
|
|
|
|
# Remove 'v' from version, prepend 'PowerShell' - to be consistent with other package names
|
|
|
|
$name = $name -replace 'v',''
|
|
|
|
$name = 'PowerShell_' + $name
|
|
|
|
return $name
|
|
|
|
}
|
|
|
|
|
2016-08-30 05:21:48 +08:00
|
|
|
# Implements AppVeyor 'on_finish' step
|
2016-08-30 04:12:01 +08:00
|
|
|
function Invoke-AppveyorFinish
|
|
|
|
{
|
2016-09-01 04:02:12 +08:00
|
|
|
try {
|
2016-08-30 04:12:01 +08:00
|
|
|
# Build packages
|
|
|
|
$packages = Start-PSPackage
|
2016-09-01 04:02:12 +08:00
|
|
|
|
2016-11-29 09:57:04 +08:00
|
|
|
$name = Get-PackageName
|
2016-08-30 04:12:01 +08:00
|
|
|
|
|
|
|
$zipFilePath = Join-Path $pwd "$name.zip"
|
|
|
|
$zipFileFullPath = Join-Path $pwd "$name.FullCLR.zip"
|
2016-11-12 03:12:07 +08:00
|
|
|
|
2016-08-30 04:12:01 +08:00
|
|
|
Add-Type -assemblyname System.IO.Compression.FileSystem
|
|
|
|
Write-Verbose "Zipping ${env:CoreOutput} into $zipFilePath" -verbose
|
|
|
|
[System.IO.Compression.ZipFile]::CreateFromDirectory($env:CoreOutput, $zipFilePath)
|
|
|
|
Write-Verbose "Zipping ${env:FullOutput} into $zipFileFullPath" -verbose
|
|
|
|
[System.IO.Compression.ZipFile]::CreateFromDirectory($env:FullOutput, $zipFileFullPath)
|
2016-09-01 04:02:12 +08:00
|
|
|
|
2016-08-30 04:12:01 +08:00
|
|
|
$artifacts = New-Object System.Collections.ArrayList
|
|
|
|
foreach ($package in $packages) {
|
2016-11-24 08:38:50 +08:00
|
|
|
$null = $artifacts.Add($package)
|
2016-08-30 04:12:01 +08:00
|
|
|
}
|
2016-09-01 04:02:12 +08:00
|
|
|
|
2016-11-24 08:38:50 +08:00
|
|
|
$null = $artifacts.Add($zipFilePath)
|
|
|
|
$null = $artifacts.Add($zipFileFullPath)
|
2016-08-30 04:12:01 +08:00
|
|
|
|
|
|
|
if ($env:APPVEYOR_REPO_TAG_NAME)
|
|
|
|
{
|
2016-09-01 04:02:12 +08:00
|
|
|
# ignore the first part of semver, use the preview part
|
|
|
|
$preReleaseVersion = ($env:APPVEYOR_REPO_TAG_NAME).Split('-')[1]
|
2016-08-30 04:12:01 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-09-01 04:02:12 +08:00
|
|
|
$previewLabel = (git describe --abbrev=0).Split('-')[1].replace('.','')
|
|
|
|
if(Test-DailyBuild)
|
|
|
|
{
|
|
|
|
$previewLabel= "daily-{0}" -f $previewLabel
|
|
|
|
}
|
|
|
|
|
|
|
|
$preReleaseVersion = "$previewLabel-$($env:APPVEYOR_BUILD_NUMBER.replace('.','-'))"
|
2016-08-30 04:12:01 +08:00
|
|
|
}
|
|
|
|
|
2016-09-01 04:02:12 +08:00
|
|
|
# only publish to nuget feed if it is a daily build and tests passed
|
|
|
|
if((Test-DailyBuild) -and $env:TestPassed -eq 'True')
|
2016-08-30 04:12:01 +08:00
|
|
|
{
|
|
|
|
Publish-NuGetFeed -OutputPath .\nuget-artifacts -VersionSuffix $preReleaseVersion
|
|
|
|
}
|
|
|
|
|
2016-11-24 08:38:50 +08:00
|
|
|
$nugetArtifacts = Get-ChildItem .\nuget-artifacts -ErrorAction SilentlyContinue | ForEach-Object { $_.FullName }
|
2016-12-02 04:58:14 +08:00
|
|
|
|
|
|
|
if($nugetArtifacts)
|
|
|
|
{
|
|
|
|
$artifacts.AddRange($nugetArtifacts)
|
|
|
|
}
|
2016-08-30 04:12:01 +08:00
|
|
|
|
|
|
|
$pushedAllArtifacts = $true
|
2016-09-01 04:02:12 +08:00
|
|
|
$artifacts | ForEach-Object {
|
2016-08-30 04:12:01 +08:00
|
|
|
Write-Host "Pushing $_ as Appveyor artifact"
|
|
|
|
if(Test-Path $_)
|
|
|
|
{
|
|
|
|
if($env:Appveyor)
|
|
|
|
{
|
|
|
|
Push-AppveyorArtifact $_
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-09-01 04:02:12 +08:00
|
|
|
$pushedAllArtifacts = $false
|
|
|
|
Write-Warning "Artifact $_ does not exist."
|
2016-08-30 04:12:01 +08:00
|
|
|
}
|
2016-09-01 04:02:12 +08:00
|
|
|
}
|
2016-08-30 04:12:01 +08:00
|
|
|
if(!$pushedAllArtifacts)
|
|
|
|
{
|
2016-09-01 04:02:12 +08:00
|
|
|
throw "Some artifacts did not exist!"
|
2016-08-30 04:12:01 +08:00
|
|
|
}
|
2016-09-01 04:02:12 +08:00
|
|
|
}
|
|
|
|
catch {
|
2016-08-30 04:12:01 +08:00
|
|
|
Write-Host -Foreground Red $_
|
2016-09-01 04:02:12 +08:00
|
|
|
}
|
|
|
|
}
|