---
# Agent queue
queue: "Default"

# Additional variables
variables: {}

# Restore
restoreArguments: ""

# Build
buildProjects: "**/*.sln"
buildArguments: ""
buildConfiguration: "Debug"

# Test
testProjects: "**/*test*.csproj"

# Publish
publishWebProjects: False
publishArguments: ""

# # 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: "Build"
    target:
      type: queue
      name: {{queue}}
    jobs:
      - name: "Build"
        variables:
          # - name: BuildConfiguration
          #   value: "{{buildConfiguration}}"
          # - name: BuildPlatform
          #   value: "{{buildPlatform}}"
          {{#each variables}}
          - name: "{{@key}}"
            value: "{{this}}"
          {{/each}}
        steps:
          - phase: preRestore
          - phase: restore
            steps:
              - task: DotNetCoreCLI@0.*
                display: Restore
                inputs:
                  command: restore
                  publishWebProjects: true
                  projects: "{{buildProjects}}"
                  arguments: "{{restoreArguments}}"
                  zipAfterPublish: true
          - phase: postRestore
          - phase: preBuild
          - phase: build
            steps:
              - task: DotNetCoreCLI@0.*
                display: Build
                inputs:
                  command: build
                  publishWebProjects: true
                  projects: "{{buildProjects}}"
                  arguments: "--configuration $(buildConfiguration) {{buildArguments}}"
                  zipAfterPublish: true
          - phase: postBuild
          - phase: preTest
          - phase: test
            steps:
              - task: DotNetCoreCLI@0.*
                display: Test
                inputs:
                  command: test
                  publishWebProjects: true
                  projects: "{{testProjects}}"
                  arguments: "--configuration $(buildConfiguration) --logger:trx {{testArguments}}"
                  zipAfterPublish: true
          - phase: postTest
          - phase: prePublish
          - phase: publish
            steps:
              - task: DotNetCoreCLI@0.*
                display: Publish
                inputs:
                  command: publish
                  publishWebProjects: "{{publishWebProjects}}"
                  projects: ""
                  arguments: "--configuration $(buildConfiguration) --output $(build.artifactstagingdirectory) --framework netcoreapp1.1 {{publishArguments}}"
                  zipAfterPublish: true
          - phase: postPublish
          - phase: preTestResults
          - phase: testResults
            steps:
              - task: PublishTestResults@2.*
                display: Publish Test Results
                inputs:
                  testRunner: VSTest,
                  testResultsFiles: "**/TestResults/*.trx",
                  searchFolder: "$(System.DefaultWorkingDirectory)",
                  mergeTestResults: "true",
                  testRunTitle: "",
                  platform: "",
                  configuration: "",
                  publishRunAttachments: "true"
          - phase: postTestResults
          - phase: preArtifact
          - phase: artifact
            steps:
              - task: PublishBuildArtifacts@1.*
                display: Publish Artifact
                inputs:
                  PathtoPublish: "$(build.artifactstagingdirectory)",
                  ArtifactName: WebApp,
                  ArtifactType: Container,
                  TargetPath: "\\\\my\\share\\$(Build.DefinitionName)\\$(Build.BuildNumber)"
          - phase: postArtifact
