#! /usr/bin/env bash cd "$(git rev-parse --show-toplevel)" || exit REPO_ROOT="$(pwd)" # Only regenerate the endpoint index if the spec build succeeded, so a failed # build can't render docs/endpoint-index.md from a stale/partial v1.json. # # A full `dotnet build` MUST run before the doc-gen target: OpenApiGenerateDocumentsOnBuild # is false, so `-t:GenerateOpenApiDocuments` alone does NOT compile the project — it invokes # dotnet-getdocument against ErsatzTV.dll + ErsatzTV.deps.json, which don't exist in a clean # tree (e.g. the CI api-docs job, which only restores). Without the build the target fails with # "The specified deps.json … does not exist" (exit 129). Build first, then generate. # # LOCAL-DEV SHARP EDGE: if the project is ALREADY built and nothing changed, MSBuild skips the # document-generation work but still runs RenameOpenApiFiles (AfterTargets), whose Move then fails # with MSB3680 "ErsatzTV.json does not exist" — because nothing produced it. The script correctly # exits non-zero, but a caller that pipes this (`./scripts/update-openapi.sh | tail`) sees the # PIPELINE's status, i.e. tail's 0, and reads a no-op as success — leaving stale artifacts to fail # the blocking api-docs CI job. Before verifying artifacts are current, `touch` a file the project # compiles (or check this script's own exit status, unpiped). CI is unaffected: it restores into a # clean tree, so the generation never skips. (cd ErsatzTV && dotnet build && dotnet build -t:GenerateOpenApiDocuments) || exit cd "$REPO_ROOT" || exit python3 scripts/generate-endpoint-index.py