# =============================================================================
# This pipeline (teams.net-pr) builds, tests, and packs the SDK (excluding core/).
# PR trigger: main and release/* branches. No CI trigger.
# =============================================================================

trigger: none

pr:
  branches:
    include:
      - main
      - release/*
  paths:
    exclude:
      - core/**

pool:
  vmImage: 'ubuntu-22.04'

variables:
  buildConfiguration: 'Release'

stages:
- stage: Build_Test_Pack
  jobs:
  - job: BuildTestPack
    displayName: 'Build, Test, and Pack'
    steps:

      - task: UseDotNet@2
        displayName: 'Use .NET 8'
        inputs:
          packageType: 'sdk'
          version: '8.0.x'

      - task: UseDotNet@2
        displayName: 'Use .NET 10'
        inputs:
          packageType: 'sdk'
          version: '10.0.x'

      - script: dotnet restore 
        displayName: 'Restore'

      - script: dotnet build --no-restore --configuration $(buildConfiguration)
        displayName: 'Build'

      - script: dotnet test --no-build --configuration $(buildConfiguration) --logger trx
        displayName: 'Test'

      - task: PublishTestResults@2
        displayName: 'Publish Test Results'
        condition: succeededOrFailed()
        inputs:
          testResultsFormat: 'VSTest'
          testResultsFiles: '**/*.trx'
          mergeTestResults: true

      - script: dotnet pack --no-build -o $(Build.ArtifactStagingDirectory) /p:SymbolPackageFormat=snupkg --configuration $(buildConfiguration)
        displayName: 'Pack'

      - task: PublishPipelineArtifact@1
        displayName: 'Publish NuGet Packages as Pipeline Artifact'
        inputs:
          targetPath: '$(Build.ArtifactStagingDirectory)'
          artifact: 'Packages'
          publishLocation: 'pipeline'
