$project = Join-Path $PSScriptRoot "OpsDeskPro.csproj"

if (-not (Test-Path $project)) {
    throw "Project file not found: $project"
}

Push-Location $PSScriptRoot
try {
    Write-Host ""
    Write-Host "====================================================" -ForegroundColor Cyan
    Write-Host " OpsDesk Career Suite - Windows IT Portfolio App " -ForegroundColor Cyan
    Write-Host "====================================================" -ForegroundColor Cyan
    Write-Host ""

    dotnet restore $project
    if ($LASTEXITCODE -ne 0) {
        throw "dotnet restore failed."
    }

    dotnet build $project
    if ($LASTEXITCODE -ne 0) {
        throw "dotnet build failed."
    }

    dotnet run --project $project
    if ($LASTEXITCODE -ne 0) {
        throw "dotnet run failed."
    }
}
finally {
    Pop-Location
}
