Add publish.ps1, and stop trimming release artifacts #5
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/publish-script"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Adds
publish.ps1, and removesPublishTrimmedfrom the release workflow after finding it produces artifacts that cannot start.publish.ps1
Wraps the
dotnet publishinvocation so the flag combination does not have to be remembered. Output goes topublish/<runtime>/, which is already gitignored (.gitignore:4).Tests run first by default, so a failing build produces no artifact. The script prints the version read from the csproj, the resolved output paths and sizes, and the next deployment steps.
The trimming bug
I built the trimmed variant to check whether the release workflow was safe. It is not.
PublishTrimmeddisables reflection-based serialization.SiteConfigandSiteStateare both bound withSystem.Text.Jsonreflection, so the build emits six IL2026 warnings and the resulting binary throws before reading the first config file:release.ymlcarried-p:PublishTrimmed=trueon both the linux-x64 and win-x64 steps, so tagging anyv*release would have published two artifacts that cannot start. No tags exist in this repository yet, so nothing broken was ever shipped. Removed from both steps.Size difference, for the record: 14.1 MB trimmed and broken, 64.4 MB untrimmed and working.
publish.ps1deliberately offers no trimming switch, because a switch that produces a non-functional binary is a trap. Re-enabling it would need aJsonSerializerContextsource generator for those two models, and that requirement is recorded in the script header,README.md, andARCHITECTURE.mdso it is not naively re-added.Verification
publish.ps1parse-validated with[Parser]::ParseFile, 0 errors. CRLF throughout, comment-based help present.dotnet test: 22 passed, 0 failed.History reconciliation
This branch was cut from
devand then fast-forwarded toorigin/main, so it also carries the release merge commit thatdevwas missing. Merging this clears the "out-of-date with the base branch" warning without needing a separate reconcile PR.The merge was a genuine fast-forward with no content change, because
mainis a strict descendant ofdevhere (git merge-base --is-ancestor origin/dev origin/mainreturns 0).Assumptions
publish/is the intended output location, per the existing.gitignoreentry.-SkipTestsexists for the case where they have just been run.publish.ps1 wraps the dotnet publish invocation so a developer does not have to remember the flag combination. It runs the tests first so a failing build produces no artifact, writes self-contained single-file binaries to publish/ (already gitignored), and supports -Runtime all for cross-platform builds. Building the trimmed variant to check whether the release workflow was safe showed that it is not. PublishTrimmed disables reflection-based serialization, and both SiteConfig and SiteState are bound with System.Text.Json reflection. The build emits six IL2026 warnings and the resulting binary throws before reading the first config file: System.InvalidOperationException: Reflection-based serialization has been disabled for this application. release.yml carried -p:PublishTrimmed=true on both the linux-x64 and win-x64 steps, so tagging any v* release would have published two artifacts that cannot start. No tags exist yet, so nothing broken was ever shipped. Removed from both steps. publish.ps1 deliberately offers no trimming switch, because a switch that produces a non-functional binary is a trap. Re-enabling it would require a JsonSerializerContext source generator for those two models; that requirement is recorded in the script header, README.md, and ARCHITECTURE.md so it is not naively re-added. Verified: untrimmed publish output runs all five checks against the live site and exits 0. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>