Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable assembly trimming and single-file publish on all platforms #1419

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

mjcheetham
Copy link
Collaborator

@mjcheetham mjcheetham commented Sep 20, 2023

Depends on: #1417 and #1418

Now that we no longer have to target .NET Framework on Windows, and we are using the latest .NET (.NET 8) and CoreCLR, we can take advantage of the mature and stable assembly trimming logic in the SDK.

This will allow us to reduce the number and sizes of binaries that we produce and ship. In addition we enable single-file publishing on all platforms that links all CIL code in to the same entry executable. Native dependencies remain separate files, such as the MSAL runtime, and Avalonia graphics library dependencies.

In order to enable trimming we had to:

  • Use source generation in System.Text.Json
  • Enable compiled bindings in Avalonia components

** TODO: size comparisons **

Fixes: #113

@mjcheetham mjcheetham force-pushed the publish-trim branch 6 times, most recently from 4fa39ba to a958838 Compare September 22, 2023 19:05
Annotate any OS or platform specific code with the new
(Un)SupportedOSPlatform(Guard) attributes and update various platform
util methods to use the OperatingSystem.Is<platform> methods.

This will help ensure we're not missing any OS checks in the future.

For test projects we ignore these warnings since we're using skipping
Xunit tests that are not applicable for the current platform already,
making these warnings just noise.
Add a workaround for a bug in MSAL's loading of native dependencies when
published as a single file bundle.

Using the IncludeAddContentForSelfExtract option will cause all managed
and native dependencies to be extracted on first launch to a temporary
directory, and executed from there.

This only affects Windows as only Windows has support for the MSAL
runtime that requires the native dependencies.
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.

Migrate from .NET Framework on Windows
1 participant