name: Build

on:
  workflow_dispatch:
  push:
    paths:
      - .github/workflows/build.yml
      - ./src/Prospect.Agent/**
      - ./src/Prospect.Launcher/**

env:
  PROJ_AGENT: ./src/Prospect.Agent/Prospect.Agent.vcxproj
  PROJ_LAUNCHER: ./src/Prospect.Launcher/Prospect.Launcher.csproj

jobs:
  build:
    runs-on: windows-2022
    steps:
    - uses: actions/checkout@v4

    - name: Setup Dotnet 
      uses: actions/setup-dotnet@v4
      with:
        dotnet-version: '8.0.x'

    - name: Setup MSBuild
      uses: microsoft/setup-msbuild@v2.0.0

    - name: Restore NuGet
      run: dotnet restore ${{env.PROJ_LAUNCHER}}

    - name: Install Prospect.Agent dependencies
      run: |
        vcpkg integrate install

    - name: Build Prospect.Agent
      run: msbuild /m /p:Configuration=Release /p:Platform=x64 ${{env.PROJ_AGENT}}

    - name: Build Prospect.Launcher
      run: dotnet publish -o ./Prospect-Launcher -r win-x64 --no-self-contained -c Release -v minimal ${{env.PROJ_LAUNCHER}}

    - uses: actions/upload-artifact@v4
      with:
        name: Prospect.Launcher
        path: ./Prospect-Launcher
        retention-days: 14
