Ming
Ming

Reputation: 525

reduce the size of a unpacked Winui 3 application

I have a WinUi 3 (c#)solution that contains 3 projects: A, B, C.

A: main application(exe) depends on B,C.

B: dll project depends on C.

c: dll project.

Now I like to build the solution as a unpacked application and pack it into a wix installer, so I want to reduce the file number of unpacked application as much as I can.

I added following property in project file of A for building.

<WindowsPackageType>None</WindowsPackageType> 

Here is the output folder after building:

B.dll
B.pri
A.deps.json
A.dll
A.exe
A.pri
A.runtimeconfig.json
C.dll
C.pri
WinUI.Icon.dll
WinUI.Token.dll
Microsoft.Extensions.DependencyInjection.Abstractions.dll
Microsoft.Extensions.DependencyInjection.dll
Microsoft.InteractiveExperiences.Projection.dll
Microsoft.Windows.ApplicationModel.DynamicDependency.Projection.dll
Microsoft.Windows.ApplicationModel.Resources.Projection.dll
Microsoft.Windows.ApplicationModel.WindowsAppRuntime.Projection.dll
Microsoft.Windows.AppLifecycle.Projection.dll
Microsoft.Windows.AppNotifications.Builder.Projection.dll
Microsoft.Windows.AppNotifications.Projection.dll
Microsoft.Windows.PushNotifications.Projection.dll
Microsoft.Windows.SDK.NET.dll
Microsoft.Windows.Security.AccessControl.Projection.dll
Microsoft.Windows.System.Power.Projection.dll
Microsoft.Windows.System.Projection.dll
Microsoft.Windows.Widgets.Providers.Projection.dll
Microsoft.WindowsAppRuntime.Bootstrap.Net.dll
Microsoft.WinUI.dll
Microsoft.Xaml.Interactions.dll
Microsoft.Xaml.Interactivity.dll
WinRT.Runtime.dll
CommunityToolkit.Mvvm.dll
Removed   // put unneeded files in this folder  
runtimes  // folder contains win10-x64\native\Microsoft.WindowsAppRuntime.Bootstrap.dll
Assets    // contains the jpg and icon files referenced by application.

Here are the files I put in the "Removed" folder cause the application can be launched without them.

  1. all language folders like "xx-xx";
  2. .xaml and .xbf files.
  3. pdb files and unneeded runtime folder like "win10-arm64:

Question:

Is this the best I can do? Is it possible to remove following files or folder?

  1. A.deps.json and A.runtimeconfig.json.
  2. "Assets" folder
  3. pri files.

Upvotes: 1

Views: 334

Answers (1)

Katana
Katana

Reputation: 1

currently this is not possible, but mybe you can use vs post-build event for removing languages folder, however if you want to reduce your app size, best option is to use Trimming https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/trim-self-contained

Upvotes: 1

Related Questions