Skip to content

Enable trimming to cut install size from 221 MB to 98 MB - #26

Merged
damianh merged 3 commits into
mainfrom
dh/reduce-install-size
Jul 26, 2026
Merged

damianh merged 3 commits into
mainfrom
dh/reduce-install-size

Conversation

@damianh

@damianh damianh commented Jul 26, 2026 •

Copy link
Copy Markdown
Owner

The installed footprint was ~221 MB, compared to ~2 MB for comparable native tools like Browser Tamer. The self-contained WinUI publish shipped the entire untrimmed BCL plus the full Windows SDK projection (Microsoft.Windows.SDK.NET.dll alone is 52.8 MB).

Enabling PublishTrimmed drops the publish output from 220.7 MB to ~110 MB (-50%). The remaining floor is the native WinUI runtime (~40 MB), which trimming cannot touch.

Changes

  • PublishTrimmed=true with TrimMode=partial in BrowserWrangler.csproj, so CI and local publishes both get trimmed output; only assemblies that opt in via IsTrimmable are processed
  • Config and rule-hit log JSON moved from reflection-based JsonSerializerOptions to source-generated JsonSerializerContexts (AppConfigJsonContext, RuleHitLogJsonContext), preserving the exact serialization behavior (indentation, WhenWritingDefault, string enums). This eliminates all IL2026 trim warnings from app code.
  • Release workflow step name updated to reflect trimming

Trim safety

  • The UI defines no reflection-based XAML bindings; views are populated in code-behind
  • No Activator/GetType() reflection in app code
  • Only remaining trim warnings are the known IL2104s from Microsoft.Windows.SDK.NET and WinRT.Runtime
  • All 122 Core tests pass

Smoke test

Built the Inno Setup installer locally from a trimmed publish and installed it as an upgrade over the previous untrimmed release:

  • Installer: 31.6 MB; Apps list shows 115 MB installed (was 225 MB)
  • App launches and is responsive; About page reports correct version/runtime/WASDK info, config loads via the source-generated JSON context

Copilot AI review requested due to automatic review settings July 26, 2026 11:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Reduces publish size by enabling trimming and replacing reflection-based JSON serialization with source-generated contexts.

Changes:

  • Enables trimmed, self-contained publishing.
  • Adds source-generated JSON contracts for configuration and rule-hit logs.
  • Updates the release workflow label.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/BrowserWrangler/BrowserWrangler.csproj Enables publish trimming.
src/BrowserWrangler.Core/Configuration/ConfigStore.cs Uses generated JSON metadata.
src/BrowserWrangler.Core/Configuration/AppConfigJsonContext.cs Defines the configuration JSON contract.
src/BrowserWrangler.Core/Logging/RuleHitLogStore.cs Uses generated JSON metadata.
src/BrowserWrangler.Core/Logging/RuleHitLogJsonContext.cs Defines the log-entry JSON contract.
.github/workflows/release.yml Reflects trimming in the publish-step name.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/BrowserWrangler/BrowserWrangler.csproj
Copilot AI review requested due to automatic review settings July 26, 2026 11:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment thread src/BrowserWrangler/BrowserWrangler.csproj Outdated
Copilot AI review requested due to automatic review settings July 26, 2026 12:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

damianh and others added 3 commits July 26, 2026 14:40
Self-contained WinUI publish shipped the full untrimmed BCL and
Windows SDK projection (220 MB installed). PublishTrimmed drops it
to ~98 MB. JSON (de)serialization moved to source-generated
contexts so config and rule-hit log survive trimming; XAML already
uses x:Bind throughout, so no other reflection hazards.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Only assemblies that opt in via IsTrimmable get trimmed; non-compatible
dependencies ship intact. The WASDK/WinRT assemblies self-declare
trimmable, so output size is unchanged vs full mode.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
No XAML bindings exist; views are populated in code-behind.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 26, 2026 12:40
@damianh
damianh force-pushed the dh/reduce-install-size branch from 3746b2d to ff29fcd Compare July 26, 2026 12:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

@damianh
damianh merged commit 544ef3d into main Jul 26, 2026
2 checks passed
@damianh
damianh deleted the dh/reduce-install-size branch July 26, 2026 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants