trigger:
  branches:
    include:
    - '*'
  paths:
    exclude:
    - doc/*
    - doc/*/*
    - .github/*
    - .github/*/*
    - .appveyor.yml
    - .travis.yml
    - CONTRIBUTORS
    - COPYING
    - README.md
    - gen-msvc-project.bat
    - setup.bat

pr:
  branches:
    include:
    - '*'
  paths:
    exclude:
    - doc/*
    - doc/*/*
    - .github/*
    - .github/*/*
    - .appveyor.yml
    - .travis.yml
    - CONTRIBUTORS
    - COPYING
    - README.md
    - gen-msvc-project.bat
    - setup.bat

jobs:
- job:
  pool:
    vmImage: windows-latest
  strategy:
    matrix:
      Release:
        configuration: Release
      Debug:
        configuration: Debug

  steps:
  - checkout: self
    submodules: recursive

  - script: |
      mkdir build
      cd build
      cmake .. -G "Visual Studio 16 2019" -A Win32
    displayName: 'Before build'

  - script: cmake --build . --config %configuration%
    workingDirectory: build
    displayName: 'Build'

  - task: CopyFiles@2
    displayName: 'Copy files to $(Build.ArtifactStagingDirectory)'
    condition: and(succeeded(), eq(variables['Agent.JobName'], 'Release'))
    inputs:
      Contents: |
          COPYING
          README.md
          build\bin\$(configuration)\cxbx.exe
          build\bin\$(configuration)\cxbxr-ldr.exe
          build\bin\$(configuration)\cxbxr-emu.dll
          build\bin\$(configuration)\glew32.dll
          build\bin\$(configuration)\subhook.dll
          build\bin\$(configuration)\SDL2.dll
          build\bin\$(configuration)\cxbxr-debugger.exe
          build\bin\$(configuration)\capstone.dll
          build\bin\$(configuration)\cx_x86.dll
      TargetFolder: '$(Build.ArtifactStagingDirectory)'
      flattenFolders: true

  - publish: $(Build.ArtifactStagingDirectory)
    artifact: $(configuration)
    condition: and(succeeded(), eq(variables['Agent.JobName'], 'Release'))
    displayName: Publish artifact(s)
