[CmdletBinding()]
param([switch]$SkipProductionDeploy)

Set-StrictMode -Version 2.0
$ErrorActionPreference = 'Stop'
$ui = Join-Path $PSScriptRoot 'updater\Vendoo.Updater.UI.ps1'
try {
  & $ui @PSBoundParameters
} catch {
  try {
    Add-Type -AssemblyName PresentationFramework
    [System.Windows.MessageBox]::Show(
      "Der Vendoo-Updater konnte nicht gestartet werden.`n`n$($_.Exception.Message)`n`nBitte die Datei logs\updater-bootstrap.log mitsenden.",
      'Vendoo Updater – Startfehler',
      [System.Windows.MessageBoxButton]::OK,
      [System.Windows.MessageBoxImage]::Error
    ) | Out-Null
  } catch {}
  $packageRoot = (Resolve-Path -LiteralPath (Join-Path $PSScriptRoot '..') -ErrorAction Stop).ProviderPath.TrimEnd([System.IO.Path]::DirectorySeparatorChar,[System.IO.Path]::AltDirectorySeparatorChar)
  $fallback = Join-Path $packageRoot 'logs\updater-bootstrap.log'
  New-Item -ItemType Directory -Path (Split-Path -Parent $fallback) -Force | Out-Null
  "$(Get-Date -Format o) $($_.Exception.ToString())" | Add-Content -LiteralPath $fallback -Encoding UTF8
}
