# Pull request validation pipeline config

trigger:
- master

pool:
  vmImage: 'windows-latest'

variables:
  buildConfiguration: 'Release'
  outputDirectory: '$(build.binariesDirectory)/$(buildConfiguration)'
  buildPlatform: 'x86|x64|ARM'

steps:
- task: NuGetToolInstaller@1
  displayName: 'Install NuGet Tool'

- task: NuGetCommand@2
  displayName: 'Restore Solution'
  inputs:
    restoreSolution: '**/*.sln'

# - task: ResharperCli@2
#   displayName: 'RESharper CLI Code Analyzer'
#   inputs:
#     solutionOrProjectPath: 'GUT.Schedule/GUTSchedule.sln'
#     failBuildLevelSelector: Hint
#     failBuildOnCodeIssues: false

- task: XamarinAndroid@1
  displayName: 'Build Android'
  inputs:
    projectFile: '**/**.Droid.csproj'
    outputDirectory: '$(outputDirectory)'
    configuration: '$(buildConfiguration)'
    msbuildVersionOption: 'latest'
    msbuildArchitectureOption: 'x64'
    jdkOption: 'JDKVersion'

- task: VSBuild@1
  displayName: 'Build UWP'
  inputs:
    platform: 'x64'
    solution: '**/**.UWP.csproj'
    configuration: '$(buildConfiguration)'
    msbuildArgs: '/p:AppxPackageSigningEnabled=false'

- task: FileTransform@2
  displayName: 'Update test credential'
  inputs:
    folderPath: '$(System.DefaultWorkingDirectory)'
    xmlTransformationRules: 
    jsonTargetFiles: '**/TestCredential.json'

- task: VSBuild@1
  displayName: 'Build Tests'
  inputs:
    solution: '**\*.Test.csproj'

- task: VSTest@2
  displayName: 'Run Tests'
  inputs:
    testSelector: 'testAssemblies'
    testAssemblyVer2: |
      **\*.Test.dll
      !**\*TestAdapter.dll
      !**\obj\**
    searchFolder: '$(System.DefaultWorkingDirectory)'