image: Visual Studio 2019

environment:
  APPVEYOR_SAVE_CACHE_ON_ERROR: "true"
  APPVEYOR_RDP_PASSWORD: Vercoe123
  CSOUND_VERSION: 6.15.0
  VCPKGDir: C:\Tools\vcpkg
  VSGENERATOR: Visual Studio 16 2019

platform: x64
configuration: Release

init:
  - set CSOUND_HOME=%APPVEYOR_BUILD_FOLDER%
  - set PYTHON=C:\Python27-x64\python.exe
  - ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
  - set /p RedistVersion=<"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\Microsoft.VCRedistVersion.default.txt"
  - set VCREDIST_CRT_DIR=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Redist\MSVC\%RedistVersion%\x64\Microsoft.VC142.CRT
  - set VCREDIST_CXXAMP_DIR=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Redist\MSVC\%RedistVersion%\x64\Microsoft.VC142.CXXAMP
  - set VCREDIST_OPENMP_DIR=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Redist\MSVC\%RedistVersion%\x64\Microsoft.VC142.OpenMP
  - call "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Auxiliary\\Build\\vcvars64.bat"

install:
  - cd msvc
  - dir
  - choco config set --name="'webRequestTimeoutSeconds'" --value="'500'"
  - powershell -ExecutionPolicy ByPass -File downloadDependencies.ps1 -vsGenerator "%VSGENERATOR%"
  # Download and unzip manual for inclusion with the installer
  - cd c:/
  - ps: Start-FileDownload 'https://github.com/csound/manual/releases/download/6.15.0/Csound6.15.0_manual_html.zip'
  - cmd: 7z.exe x Csound6.15.0_manual_html.zip
  - cd C:\projects\csound\

build:
  parallel: true
  project: msvc\csound-vs\Csound.sln

after_build:
  - set PATH=%PATH%;"C:\\Program Files (x86)\\Inno Setup 6"
  - iscc /dVcpkgInstallDir=%VCPKGDir%\\installed\\x64-windows-csound /omsvc installer\\windows\\csound6_x64_appveyor.iss
  - 7z a csound-windows_x86_64-%CSOUND_VERSION%-%APPVEYOR_BUILD_NUMBER%.zip %APPVEYOR_BUILD_FOLDER%\msvc\csound-vs\Release\*.exe %APPVEYOR_BUILD_FOLDER%\msvc\csound-vs\Release\csound64.lib %APPVEYOR_BUILD_FOLDER%\include\ %APPVEYOR_BUILD_FOLDER%\msvc\csound-vs\Release\*.dll %APPVEYOR_BUILD_FOLDER%\msvc\csound-vs\Release\*.pyd %APPVEYOR_BUILD_FOLDER%\msvc\csound-vs\*.jar %APPVEYOR_BUILD_FOLDER%\msvc\csound-vs\*.py 
  - 7z l csound-windows_x86_64-%CSOUND_VERSION%-%APPVEYOR_BUILD_NUMBER%.zip

test_script:
  - cmake --build msvc\csound-vs --target csdtests

artifacts:
  - path: csound-windows_x86_64-*.zip
    name: Csound Binaries
    type: zip
  - path: msvc/Csound6_x64*.exe
    name: Csound Installer
    type: exe

cache:
 - C:\Tools\vcpkg\installed -> C:\projects\csound\msvc\downloadDependencies.ps1
 - C:\projects\csound\msvc\cache
 - C:\ProgramData\chocolatey\bin -> appveyor.yml 
 - C:\ProgramData\chocolatey\lib -> appveyor.yml

deploy:
  release: csound-$(csound_version)
  description: 'Csound Windows installer.'
  provider: GitHub
  auth_token:
    secure: puEAPJVkwT2mZwhobSNpk5LhUEP+61K9j6T66qIXKFk=
  artifact: msvc/csound-windows_x86_64*.exe
  draft: true
  prerelease: true
  on:
    branch: develop
    appveyor_repo_tag: true        # deploy on tag push only

notifications:
  - provider: Email
    to:
      - CSOUND-DEV@listserv.heanet.ie
    subject: 'Build {{status}}'     # optional
    on_build_success: false
    on_build_failure: true
    on_build_status_changed: false

#  - provider: Slack
#    auth_token:
#      secure: kBl9BlxvRMr9liHmnBs14A==
#    channel: development
#    template: "{{template_variable_1}}, {{template_variable_2}}, ..."
