---
# Agent queue
queue: ""

# Job expansion
matrix:
  - buildConfiguration: release
    buildPlatform: any cpu

# Additional variables
variables: {}

# Restore
restoreSolution: "s/**/*.sln"
restoreNuGetVersion: 3.3.0

# Build
buildSolution: "s/**/*.sln"
buildArguments: ""
buildClean: false
buildVSVersion: 15.0

# Test
testPattern:
  - "**/*test*.dll"
  - "!**/obj/**"
testRoot: s

# Symbols
symbolsPattern: "**/bin/**/*.pdb"
symbolsRoot: s
symbolsStore: ""
symbolsSkipIndex: false
symbolsWarnIfNotIndexed: false

# Stage and publish drop
copyPattern:
  - "**"
copyRoot: s
dropStagingPath: "$(Build.ArtifactStagingDirectory)"
dropArtifactName: "drop-$(BuildConfiguration)-$(BuildPlatform)"
dropType: Container # Container or FilePath
dropPath: "" # Only required if FilePath
---

# Self repo
resources:
  - name: s
    type: self

phases:
  - name: "VS Build"
    target:
      type: queue
      name: {{queue}}
    jobs:
      {{#matrix}}
      - name: "build-{{buildConfiguration}}-{{buildPlatform}}"
        variables:
          - name: BuildConfiguration
            value: "{{buildConfiguration}}"
          - name: BuildPlatform
            value: "{{buildPlatform}}"
          {{#each @root.variables}}
          - name: "{{@key}}"
            value: "{{this}}"
          {{/each}}
        steps:
          - phase: preRestore
          - phase: restore
            steps:
              - task: NuGetInstaller@0.*
                inputs:
                  solution: "{{@root.restoreSolution}}"
                  restoreMode: restore
                  nuGetVersion: "{{@root.restoreNuGetVersion}}"
          - phase: postRestore
          - phase: preBuild
          - phase: build
            steps:
              - task: VSBuild@1.*
                inputs:
                  solution: "{{@root.buildSolution}}"
                  msbuildArgs: "{{@root.buildArguments}}"
                  configuration: "{{buildConfiguration}}"
                  platform: "{{buildPlatform}}"
                  clean: "{{@root.buildClean}}"
                  vsVersion: "{{@root.buildVSVersion}}"
                  msbuildArchitecture: x86
                  logProjectEvents: false
                  createLogFile: false
          - phase: postBuild
          - phase: preTest
          - phase: test
            steps:
              - task: VSTest
                inputs:
                  testAssemblyVer2: "{{#each @root.testPattern}}{{#unless @first}}\n{{/unless}}{{this}}{{/each}}"
                  searchFolder: "{{@root.testRoot}}"
                  configuration: "{{buildConfiguration}}"
                  platform: "{{buildPlatform}}"
          - phase: postTest
          - phase: preSymbols
          - phase: symbols
            steps:
              - task: PublishSymbols@1.*
                inputs:
                  SearchPattern: "{{@root.symbolsPattern}}"
                  SymbolsFolder: "{{@root.symbolsRoot}}"
                  SymbolsPath: "{{@root.symbolsStore}}"
                  SkipIndexing: "{{@root.symbolsSkipIndex}}"
                  TreatNotIndexedAsWarning: "{{@root.symbolsWarnIfNotIndexed}}"
                  SymbolsArtifactName: "Symbols_{{buildConfiguration}}_{{buildPlatform}}"
          - phase: postSymbols
          - phase: preDrop
          - phase: drop
            steps:
              - task: CopyFiles@2.*
                inputs:
                  Contents: "{{#each @root.copyPattern}}{{#unless @first}}\n{{/unless}}{{this}}{{/each}}"
                  SourceFolder: "{{@root.copyRoot}}"
                  TargetFolder: "{{@root.dropStagingPath}}"
              - task: PublishBuildArtifacts@1.*
                inputs:
                  PathtoPublish: "{{@root.dropStagingPath}}"
                  ArtifactName: "{{@root.dropArtifactName}}"
                  ArtifactType: "{{@root.dropType}}"
                  TargetPath: "{{@root.dropPath}}"
          - phase: postDrop
      {{/matrix}}