param(
    [ValidateSet("Debug", "Release")]
    [string]$Configuration = "Release"
)

$ErrorActionPreference = "Stop"
$Root = Resolve-Path (Join-Path $PSScriptRoot "..")
$Project = Join-Path $Root "src\LittleSim\LittleSim.csproj"

Push-Location $Root
try {
    dotnet build LittleSim.sln -c $Configuration
    if ($LASTEXITCODE -ne 0) {
        exit $LASTEXITCODE
    }

    dotnet run --project $Project -c $Configuration --no-build @args
    exit $LASTEXITCODE
}
finally {
    Pop-Location
}
