name: Build

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]
  workflow_call:

jobs:
  build:
    runs-on: windows-latest
    env:
      solution: AmagnoVirtualPrinter.sln
      configuration: Release
    steps:
    - name: Checkout
      uses: actions/checkout@v3
      with:
        fetch-depth: 0

    # Add  MSBuild to the PATH: https://github.com/microsoft/setup-msbuild
    - name: Setup MSBuild.exe
      uses: microsoft/setup-msbuild@v1

    - name: Restore the application
      run: msbuild $env:solution /t:Restore /p:Configuration=$env:configuration
    
    - name: Build solution
      run: msbuild $env:solution /t:Rebuild /p:Configuration=$env:configuration
    - name: Create msi from PowerShell Script
      run: |
        "$Env:GITHUB_WORKSPACE\create_msi.ps1"
    - name: Upload installer artifact
      uses: actions/upload-artifact@v3
      with:
        name: installer
        path: ./AmagnoPrinterInstaller.msi
    - name: Upload files artifact
      uses: actions/upload-artifact@v3
      with:
        name: files
        path: files/**/*
