I have a Windows UI application (developed with Avalonia), a console application (which is called with command line arguments), and 2 class libraries in one solution (the UI app uses both class libraries while the console application uses just 1 class library).
I want to deploy everything using one MSIX package, but initially outside of the Microsoft Store (eventually I want it in the Microsoft Store). I've added a Windows Application Packaging Project to this solution and set some properties via the Package.appxmanifest visual designer tabs. I've also added both the UI and console applications to the WAP 'dependencies'.
Before adding the 'Extensions' section, 'Create App Packages' works fine.
I'd like to add an AppExecutionAlias to the console application so that it can be called easily (but the UI application doesn't need it - it is never called via command line). I modified the Package.appxmanifest file 'Applications' section as follows (omitting 'VisualElements' details here):
<Applications>
<Application Id="FooUI"
Executable="FooUI.exe"
EntryPoint="$targetentrypoint$">
<uap:VisualElements
... (omitted)
</uap:VisualElements>
</Application>
<Application Id="FooConsole"
Executable="FooConsole.exe"
EntryPoint="$targetentrypoint$">
<uap:VisualElements
... (omitted)
</uap:VisualElements>
<Extensions>
<uap:Extension Category="windows.appExecutionAlias">
<uap:AppExecutionAlias>
<uap:ExecutionAlias Alias="FooConsole.exe" />
</uap:AppExecutionAlias>
</uap:Extension>
</Extensions>
</Application>
</Applications>
The references at the top of the file have not been changed:
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
I get the following 2 errors in the Package.appxmanifest file:
Also, where does 'Application Id' come from? I don't see any 'Application Id' property in the solution projects. I changed them, but don't they have to sync up with something set elsewhere?
After trying various things randomly, I came across a modification of the Package.appxmanifest file which worked:
Add this to the other dead references that look like urls but don't go anywhere: xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5" and add 'uap5' to 'IgnorableNamespaces'
Manually add a new 'Application' section for the console app - this is not done by the Windows Application Packaging project! The WAP project just writes one 'Application' section to the Package.appxmanifest file even after you've added other dependency projects!
The working 'Application' section for the console app has to use a mixture of 'uap' and 'uap5' references and the console executable has to be preceded by the console csproj primary file name (I don't remember how I stumbled onto this):
<Application Id="FooConsole"
Executable="FooConsoleProject\FooConsole.exe"
EntryPoint="Windows.FullTrustApplication">
<uap:VisualElements
</uap:VisualElements>
<Extensions>
<uap5:Extension Category="windows.appExecutionAlias">
<uap5:AppExecutionAlias>
<uap5:ExecutionAlias Alias="FooConsole.exe" />
</uap5:AppExecutionAlias>
</uap5:Extension>
</Extensions>
</Application>
No existing source I looked at mentioned the combination of things I had to do to get a UI + console app in one MSIX package to work. I can't believe this is so poorly documented by Microsoft. My situation was relatively simple, but it required a week of research and a good deal of luck.