From 7c1d2aa520acac62e12b3fb9d3ff95e12929166c Mon Sep 17 00:00:00 2001 From: Sluijsens Date: Thu, 30 Jul 2026 11:10:17 +0200 Subject: [PATCH] Fixes /admin 404 by building the admin SPA before dotnet publish, not via an MSBuild target The BuildAndCopyAdminFrontend MSBuild target (BeforeTargets=Publish) never actually worked: files it created after project evaluation were silently absent from the publish output, and forcing them in via an explicit Content item collided with the SDK's own static-web-asset resolution. Verified locally with a clean obj/bin and a fresh node_modules - every deploy so far genuinely shipped without wwwroot/admin. Moves the frontend build + copy into its own CI step ahead of dotnet publish, so the SDK's ordinary wwwroot handling picks it up with no custom MSBuild involved. Also fixes unreadable badges on the website placeholder page (no explicit text color, relying on inherited body color pairing unreliably with the badge background). --- .gitea/workflows/continuous_integration.yaml | 34 ++++++++++++++++--- .../Extensions/WebsitePlaceholder.html | 3 +- .../SlpModularCms.Api.csproj | 31 ++++++++--------- 3 files changed, 47 insertions(+), 21 deletions(-) diff --git a/.gitea/workflows/continuous_integration.yaml b/.gitea/workflows/continuous_integration.yaml index 21f0e2e..bf0eb15 100644 --- a/.gitea/workflows/continuous_integration.yaml +++ b/.gitea/workflows/continuous_integration.yaml @@ -253,13 +253,29 @@ jobs: exit 1 fi - - name: Publish (test) - working-directory: src/SlpModularCms.Api + # Builds the admin SPA and lands it in wwwroot/admin *before* dotnet publish runs, as its own + # step rather than an MSBuild target hooked to Build/Publish. That was tried and reliably + # failed two different ways (see SlpModularCms.Api.csproj's comment on the topic): the SDK's + # wwwroot static-web-asset item set is fixed at project evaluation time, before any target + # runs, so files a target creates afterward never make it into the publish output; and forcing + # them in as an explicit Content item collided with the SDK's own static-web-asset resolution. + # Physically existing on disk before dotnet publish/build ever runs is the only thing that + # worked, verified locally against a clean obj/bin and a fresh node_modules. + - name: Build admin frontend + working-directory: frontend env: VITE_APP_ENV: test VITE_UMAMI_SCRIPT_URL: ${{ vars.VITE_UMAMI_SCRIPT_URL }} VITE_UMAMI_WEBSITE_ID: ${{ vars.VITE_UMAMI_WEBSITE_ID_TEST }} VITE_SENTRY_DSN: ${{ vars.VITE_SENTRY_DSN }} + run: | + pnpm install --frozen-lockfile + pnpm build + mkdir -p ../src/SlpModularCms.Api/wwwroot/admin + cp -r dist/. ../src/SlpModularCms.Api/wwwroot/admin/ + + - name: Publish (test) + working-directory: src/SlpModularCms.Api run: > dotnet publish -c Release -r ${{ env.PUBLISH_RID }} --self-contained false -o ${{ github.workspace }}/${{ env.ARTIFACT_NAME_TEST }} @@ -300,13 +316,23 @@ jobs: exit 1 fi - - name: Publish (production) - working-directory: src/SlpModularCms.Api + # See publish-test's "Build admin frontend" step for why this runs as its own step ahead of + # dotnet publish rather than an MSBuild target. + - name: Build admin frontend + working-directory: frontend env: VITE_APP_ENV: production VITE_UMAMI_SCRIPT_URL: ${{ vars.VITE_UMAMI_SCRIPT_URL }} VITE_UMAMI_WEBSITE_ID: ${{ vars.VITE_UMAMI_WEBSITE_ID_PRODUCTION }} VITE_SENTRY_DSN: ${{ vars.VITE_SENTRY_DSN }} + run: | + pnpm install --frozen-lockfile + pnpm build + mkdir -p ../src/SlpModularCms.Api/wwwroot/admin + cp -r dist/. ../src/SlpModularCms.Api/wwwroot/admin/ + + - name: Publish (production) + working-directory: src/SlpModularCms.Api run: > dotnet publish -c Release -r ${{ env.PUBLISH_RID }} --self-contained false -o ${{ github.workspace }}/${{ env.ARTIFACT_NAME_PRODUCTION }} diff --git a/src/SlpModularCms.Api/Extensions/WebsitePlaceholder.html b/src/SlpModularCms.Api/Extensions/WebsitePlaceholder.html index 2b8abf8..ff261f7 100644 --- a/src/SlpModularCms.Api/Extensions/WebsitePlaceholder.html +++ b/src/SlpModularCms.Api/Extensions/WebsitePlaceholder.html @@ -20,7 +20,7 @@ } @media (prefers-color-scheme: dark) { body { background: #141414; color: #ededed; } - code { background: #262626; } + code { background: #262626; color: #141414; } a { color: #ff6b6b; } } main { max-width: 34rem; } @@ -28,6 +28,7 @@ p { margin: 0 0 1rem; } code { background: #ececec; + color: #1a1a1a; padding: 0.15em 0.4em; border-radius: 4px; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; diff --git a/src/SlpModularCms.Api/SlpModularCms.Api.csproj b/src/SlpModularCms.Api/SlpModularCms.Api.csproj index 85c0df0..03b7bc8 100644 --- a/src/SlpModularCms.Api/SlpModularCms.Api.csproj +++ b/src/SlpModularCms.Api/SlpModularCms.Api.csproj @@ -35,22 +35,21 @@ - - $(MSBuildProjectDirectory)/../../frontend - - - - - - - - - - -