Skip to content

build(aot): enable PublishTrimmed and PublishAot now Discord.Net is gone #430

Open

Description

@credfeto

Original prompts (live chat, while working on #423 / PR #428):

with the discord lib gone I'm guessing we're not too far from enabling PublishTrimmed and PublishAot ?

we should raie that as a follow on issue after this merges

that was "for after" not wait until it merges to raise

Goal

Enable PublishTrimmed and then PublishAot for src/BuildBot/BuildBot.csproj (currently both false). Work on this starts after PR #428 (Discord.Net replaced by a webhook) has merged.

Already in place

Likely work (to be confirmed by a trial publish)

  • Start with dotnet publish -r linux-x64 -p:PublishTrimmed=true, then -p:PublishAot=true, and fix every trim/AOT warning (warnings are errors).
  • Serilog.Enrichers.Demystifier: reflection-based stack trace rewriting; probably remove (note IlcGenerateStackTraceData=false).
  • Microsoft.Extensions.Http.Polly (Polly v7) is not trim-annotated; Microsoft.Extensions.Http.Resilience (Polly v8) is the AOT-friendly option but is a new package needing owner sign-off.
  • Confirm AWSSDK.CloudFormation 4.x trim/AOT compatibility.
  • Check whether System.Reactive is still needed after refactor(discord): replace Discord.Net bot login with a Discord webhook #428's DiscordMessageSender BackgroundService change.
  • Dockerfile: an AOT build would use a runtime-deps base image; ICU is still needed (InvariantGlobalization=false).

A full implementation plan will be posted for approval before any work starts.

Activity

  1. credfeto commented on Oct 15, 2026

    @credfeto
    MemberAuthor

    Priority set by the repository owner in live chat:

    high

    High label applied.

  2. credfeto commented on Oct 15, 2026

    @credfeto
    MemberAuthor

    Note from PR #428 (owner, live chat: "q19 isn't that for when we're doing the trimming pr?"): after #428 rewrote DiscordMessageSender as a BackgroundService, no code in src uses Rx any more. System.Reactive 7.0.0 and System.Interactive.Async 7.0.1 are still referenced from src/BuildBot.ServiceModel/BuildBot.ServiceModel.csproj. Try removing both as part of this issue (keep System.Interactive.Async if the build shows its System.Linq async extensions are still used).

  3. credfeto commented on Oct 16, 2026

    @credfeto
    MemberAuthor

    Raised in the PR #428 code review (round 2): with Discord.Net gone, check whether anything still needs ICU. If nothing does, set InvariantGlobalization=true and switch from the chiseled-extra base image to the plain chiseled one (smaller image, less CVE surface). See #428 (comment).

  4. self-assigned this
    on Oct 19, 2026
  5. dnyw4l3n13 commented on Oct 19, 2026

    @dnyw4l3n13
    Collaborator

    Implementation Plan

    Files to change

    • src/BuildBot.ServiceModel/BuildBot.ServiceModel.csproj - remove System.Reactive (and System.Interactive.Async unless the build shows its async LINQ extensions are still used), per the refactor(discord): replace Discord.Net bot login with a Discord webhook #428 follow-up note.
    • src/BuildBot/BuildBot.csproj - set PublishTrimmed=true, then PublishAot=true; remove Serilog.Enrichers.Demystifier; set InvariantGlobalization=true if nothing needs ICU; review/prune TrimmerRootAssembly entries.
    • src/BuildBot/Helpers/ServerStartup.cs (and any Serilog setup) - drop the .Enrich.WithDemystifiedStackTraces() call.
    • src/BuildBot.CloudFormation/*, src/BuildBot.Discord/* (and csproj files) - fix trim/AOT warnings found in a trial publish; Polly v7 (Microsoft.Extensions.Http.Polly) usage in DiscordSetup.cs / CloudformationSetup.cs is the likely hotspot (see open questions).
    • Dockerfile - if invariant globalization is viable, switch to runtime-deps:11.0-resolute-chiseled and update the comment. The base image stays runtime-deps, which suits AOT.
    • Related unit tests (*SetupTests.cs) and CHANGELOG.md - updated to match.

    Approach

    Work in small, separately committed steps. (1) Remove unused Rx packages and confirm the build. (2) Run a trial dotnet publish -r linux-x64 -p:PublishTrimmed=true and fix every trim warning (warnings are errors). (3) Remove Demystifier. (4) Repeat with -p:PublishAot=true and fix AOT warnings, confirm AWSSDK.CloudFormation 4.x is compatible. (5) Check whether ICU is needed; if not, set InvariantGlobalization=true and use the plain chiseled image. (6) Turn the properties on in the csproj and smoke-test the published binary (startup, --health-check, /ping). Trial-publish results will be reported on the PR.

    Test strategy

    Existing unit tests must pass with the coverage ratchet intact. Evidence of success: dotnet publish for linux-x64 with PublishTrimmed and with PublishAot, both with zero warnings, and the published binary starting and answering --health-check//ping. Local container build if the sandbox allows it.

    Assumptions

    • Polly v7 (Microsoft.Extensions.Http.Polly) may emit trim/AOT warnings; replacing it needs a new package.
    • The AOT toolchain (clang/zlib) is available for the trial publish; if not, AOT validation is left to CI and noted on the PR.
    • The TrimmerRootAssembly entries may be obsolete; they are removed only if the publish and smoke test prove it safe.

    Open questions

    1. If Polly v7 is not trim/AOT-clean, may I add Microsoft.Extensions.Http.Resilience (Polly v8) as a new package? Otherwise I'd try to drop the Polly policies in favour of built-in handlers. Please approve the package or say which way to go.
    2. If the trial shows AOT is blocked by a dependency I can't fix, should I deliver PublishTrimmed only and leave PublishAot=false with a follow-up issue?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

AI-WorkWork for an AI AgentBlockedBlocked by a dependency or external factorHighHigh Priority

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions