Home > database >  How to pack a .NET 6 WPF app using Windows Application Packaging Project with Framework-Dependent?
How to pack a .NET 6 WPF app using Windows Application Packaging Project with Framework-Dependent?

Time:06-28

I have a WPF app App1 (.NET 6 with <TargetFramework>net6.0-windows</TargetFramework>) and my client would like to distribute it through MS Store so I created a Windows Application Packaging Project and add reference back to App1. Everything works well and we can publish our app except with just a Hello World project, the package size is more than 60MB (for neutral arch).

I understand it is due to it packing the whole .NET 6 with it. Is there a way to publish it using framework-dependent model instead? We don't mind user being asked to download and install it if they don't have it already installed.

CodePudding user response:

Follow these steps to create a framework-dependent MSIX package:

  • Right click on the WPF project (not the Windows Application Packaging Project) in the Solution Explorer in Visual Studio and choose Publish
  • Choose Folder as both target and specific target and accept the default location in the wizard
  • Click on the "Show all settings" link of the created publish profile and set the target runtime to win-x86 or win-x64 depending on your CPU architecture requirements
  • Make sure that the deployment mode is set to Framework-dependent
  • Click Save
  • Go to the Windows Application Packaging Project, expand the Dependencies->Applications node, select the referenced WPF application project and set its Publishing Profile property to the Properties\PublishProfiles\FolderProfile.pubxml file that you created in the previous wizard
  • Re-publish the Windows Application Packaging Project with the same CPU architecture and configuration you have configured the publishing profile for
  • Related