0

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.

Luke Vo
  • 17,859
  • 21
  • 105
  • 181

1 Answers1

2

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
mm8
  • 163,881
  • 10
  • 57
  • 88
  • I am also interested in this matter and created fresh WPF and Packaging projects in Visual Studio 17.2.5 (in win-x86 or win-x64) following your instruction as much as possible. But still the size of final appxupload file is over 60 MB. There might be something I missed. – emoacht Jun 27 '22 at 14:07
  • The you did something wrong. Did you really select the same CPU architecture and configuration in the publish wizard and the selected publishing profile? – mm8 Jun 27 '22 at 15:03
  • Such as for example `Neutral `/ `Debug (Any CPU)`? – mm8 Jun 27 '22 at 15:04
  • I have the same result as @emoacht. The final output size (..msixbundle) is still 62MB. I even tried publishing the WPF app manually and the size was ~150KB so the Publish Profile was correct. The arch should match because I cannot create app package if it doesn't match. Also using the latest VS 17.2.5. – Luke Vo Jun 27 '22 at 15:22
  • @mm8 Thanks. I haven't changed platform in both solution's properties and project's properties from default (Any CPU) to x86. After setting them to x86, and specifying win-x86, the size of appxupload file became less than 100 KB. – emoacht Jun 27 '22 at 15:27
  • It's so strange I don't know what I did wrong before, but now it works for me, upload size is 84KB. I noticed the `Publishing Profile` value wasn't showing and I had to pick it again. It's weird but I can confirm it works :) – Luke Vo Jun 27 '22 at 19:16
  • Just a follow up question: is it possible to use Neutral arch instead of specifying x64/x86 only? I tried `Portable` for WPF project but it wouldn't work as it show as "MSIL" for arch. – Luke Vo Jun 27 '22 at 19:18
  • Publishing the WAP project with a neutral archiecture works for me. The target runtime of the publish profile of the WPF project still needs to be set to win-x*. – mm8 Jun 28 '22 at 11:53