version: '{build}'
image: Visual Studio 2017
build_script:
- ps: |
    ##################################### 
    # Build, test, pack and push nugets
    #####################################

    .\\build.bat
    $BuildExitCode = $LASTEXITCODE

    ##################################### 
    # Upload test results to AppVeyor
    #####################################

    $wc = New-Object 'System.Net.WebClient'

    if (Test-Path .\\Artifacts\\Logs\\) {
        Get-ChildItem .\\Artifacts\\Logs\\*Test*.xml | %{
            $wc.UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", $_.FullName)
        }
    }

    if ($BuildExitCode -ne 0) { 
        Write-Host "Build failed with exit code $BuildExitCode."
        exit $BuildExitCode
    }
test: off
artifacts:
- path: Artifacts\UnitsNet.zip
- path: 'Artifacts\NuGet\*.nupkg' # find all NuGet packages recursively
deploy:
- provider: NuGet
  api_key:
    secure: q710an2WFRwLh6rZQ/I9nKlNt/3d5kYkdUoA5Y1a/hZLr3DGZliSayP+ejF6bj30
  skip_symbols: false
  on:
    branch: master
deploy_script:
  - appveyor DownloadFile https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
  - ps: .\nuget.exe setApiKey %api_key% -source https://www.nuget.org | out-null
  - ps: ($artifacts.values | Where-Object { $_.path -like '*.nupkg' }) | foreach-object {nuget.exe push $_.path -Source https://www.nuget.org/api/v2/package}
version: '{build}'
image: Visual Studio 2017
build_script:
- ps: |
    ##################################### 
    # Build, test, pack and push nugets
    #####################################

    .\\build.bat
    $BuildExitCode = $LASTEXITCODE

    ##################################### 
    # Upload test results to AppVeyor
    #####################################

    $wc = New-Object 'System.Net.WebClient'

    if (Test-Path .\\Artifacts\\Logs\\) {
        Get-ChildItem .\\Artifacts\\Logs\\*Test*.xml | %{
            $wc.UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", $_.FullName)
        }
    }

    if ($BuildExitCode -ne 0) { 
        Write-Host "Build failed with exit code $BuildExitCode."
        exit $BuildExitCode
    }
test: off
artifacts:
- path: Artifacts\UnitsNet.zip
- path: 'Artifacts\NuGet\*.nupkg' # find all NuGet packages recursively
deploy:
- provider: NuGet
  api_key:
    secure: q710an2WFRwLh6rZQ/I9nKlNt/3d5kYkdUoA5Y1a/hZLr3DGZliSayP+ejF6bj30
  skip_symbols: false
  on:
    branch: master
Revert "Try to fix AppVeyor build"
Revert "Try to fix AppVeyor build"

This reverts commit 507da96f2bb9dfb341b1110b289c097348748ca1.
