name: Setup .NET versions
description: Sets up one or multiple .NET versions according to target frameworks

inputs:
  target_framework:
    description: "Target frameworks which are used in projects (net6.0, netcoreapp2.2, netcoreapp3.1, etc.)"
    required: true
    type: string

runs:
  using: "composite"

  steps:
    - name: Setup .NET 9 (if needed)
      if: ${{ contains(inputs.target_framework, '9.0') }}
      uses: actions/setup-dotnet@v4
      with:
        dotnet-version: '9.0.x'

    - name: Setup .NET 8 (if needed)
      if: ${{ contains(inputs.target_framework, '8.0') }}
      uses: actions/setup-dotnet@v4
      with:
        dotnet-version: '8.0.x'

    - name: Setup .NET 7 (if needed)
      if: ${{ contains(inputs.target_framework, '7.0') }}
      uses: actions/setup-dotnet@v4
      with:
        dotnet-version: '7.0.x'

    - name: Setup .NET 6 (if needed)
      if: ${{ contains(inputs.target_framework, '6.0') }}
      uses: actions/setup-dotnet@v4
      with:
        dotnet-version: '6.0.x'

    - name: Setup .NET 5 (if needed)
      if: ${{ contains(inputs.target_framework, '5.0') }}
      uses: actions/setup-dotnet@v4
      with:
        dotnet-version: '5.0.x'

    - name: Setup .NET Core 3.1 (if needed)
      if: ${{ contains(inputs.target_framework, '3.1') }}
      uses: actions/setup-dotnet@v4
      with:
        dotnet-version: '3.1.x'

    - name: Setup .NET Core 2.0 (if needed)
      if: ${{ contains(inputs.target_framework, '2.0') }}
      uses: actions/setup-dotnet@v4
      with:
        dotnet-version: '2.0.x'
