Enable trimming to cut install size from 221 MB to 98 MB - #26
Merged
Merged
Conversation
There was a problem hiding this comment.
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.
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>
damianh
force-pushed
the
dh/reduce-install-size
branch
from
July 26, 2026 12:40
3746b2d to
ff29fcd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.dllalone is 52.8 MB).Enabling
PublishTrimmeddrops 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=truewithTrimMode=partialinBrowserWrangler.csproj, so CI and local publishes both get trimmed output; only assemblies that opt in viaIsTrimmableare processedJsonSerializerOptionsto source-generatedJsonSerializerContexts (AppConfigJsonContext,RuleHitLogJsonContext), preserving the exact serialization behavior (indentation,WhenWritingDefault, string enums). This eliminates all IL2026 trim warnings from app code.Trim safety
Activator/GetType()reflection in app codeMicrosoft.Windows.SDK.NETandWinRT.RuntimeSmoke test
Built the Inno Setup installer locally from a trimmed publish and installed it as an upgrade over the previous untrimmed release: