name: Build .NET Application

on:
  workflow_call:
    inputs:
      dotnet-version:
        required: false
        type: string
        default: '{{DOTNET_VERSION}}'
      build-configuration:
        required: false
        type: string
        default: 'Release'
      run-tests:
        required: false
        type: boolean
        default: true

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Setup .NET
        uses: actions/setup-dotnet@v4
        with:
          dotnet-version: ${{{{ inputs.dotnet-version }}}}

      - name: Restore dependencies
        run: dotnet restore

      - name: Build
        run: dotnet build --configuration ${{{{ inputs.build-configuration }}}} --no-restore

      {{#if run-tests}}
      - name: Test
        run: dotnet test --configuration ${{{{ inputs.build-configuration }}}} --no-build --verbosity normal
      {{/if}}
