Danitechnik
Danitechnik

Reputation: 431

Windows application packaging project for native AOT

I have written a small console application in C# which uses native AOT from .NET 7.0. Native AOT works perfectly for .exe deployments and drastically reduces startup times.

My project file:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <AssemblyName>console-application</AssemblyName>
    <OutputType>Exe</OutputType>
    <TargetFramework>net7.0-windows</TargetFramework>
    <Nullable>enable</Nullable>
    <PublishAot>true</PublishAot>
  </PropertyGroup>

</Project>

Now I would like to package my application as MSIX or APPX so that I can upload it to the Microsoft Store. I tried using a Windows Application Packaging Project (Documentation). In my Package.appxmanifest I could easily add an execution alias (Documentation).

The packaged application works. However, it does not use native AOT, no trimming and no single file deployment. I tried to add <RuntimeIdentifier>, <SelfContained>, and <PublishSingleFile> to my project file but the packaging project seems to ignore these settings, although they are respected by dotnet publish.

Is there a way to force a Windows Application Packaging Project to use native AOT?

Upvotes: 0

Views: 562

Answers (1)

Bogdan Mitrache
Bogdan Mitrache

Reputation: 11013

It's just a limitation of the Visual Studio Setup Project, from what we can see.

You can package your application as an MSIX using the Professional edition of Advanced Installer. Here is a guide on how to build the MSIX.

After section 3 from the tutorial go to Files and Folders page and add your binary. Then go to Application Details page, add a new application, and select your exe. These steps are not included in the tutorial linked above because the tutorial was written for existing users of Advanced Installer who already have the binaries included in the project because they were building an MSI/EXE already.

After you build the MSIX you can jump to another article on how to publish your application in the MS Store.

Disclaimer: I work on the Advanced Installer team.

Upvotes: 0

Related Questions