os:
    - "WMF 5"

environment: 
    matrix: 
    - PowerShellEdition: Desktop 
    - PowerShellEdition: Core
configuration: Release
platform: Any CPU

# clone directory
clone_folder: c:\projects\powershellget

init:
  - ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))

# Install Pester and PackageManagement modules
install:
    - ps: | 
        Import-Module .\tools\build.psm1
        Install-Dependencies

# to run your custom scripts instead of automatic MSBuild
#build_script:

# to disable automatic builds
build: off

# branches to build
branches:
  # whitelist
  only:
    - master
    - development

# Run Pester tests and store the results
test_script:
    - ps: |
        Import-Module .\tools\build.psm1
        Invoke-PowerShellGetTest
        $TestResultFilePath = Resolve-Path .\Tests\TestResults.xml
        if(Microsoft.PowerShell.Management\Test-Path -Path $TestResultFilePath -PathType Leaf) {
            (New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", $TestResultFilePath)
        }


# Upload the project along with TestResults as a zip archive
on_finish:
    - ps: |
        $stagingDirectory = (Resolve-Path ..).Path
        $zipFile = Join-Path $stagingDirectory "$(Split-Path $pwd -Leaf).zip"
        Add-Type -assemblyname System.IO.Compression.FileSystem
        [System.IO.Compression.ZipFile]::CreateFromDirectory($pwd, $zipFile)
        @(
            # You can add other artifacts here
            (ls $zipFile)
        ) | % { Push-AppveyorArtifact $_.FullName }