windowsvisual-studiopackagingsideloadingmsix

Open a Windows app programmatically, when it was installed with MSIX Application Packager


I have packaged my windows App using a Visual Studio MSIX Packaging Project: This is a sideloading app, using a certificate, not a Microsoft Store App. This is fine - I get automatic updates, and users can install the package without admin rights.

I want to be able to open this app from another app. Before this was easy - just call Process.Start with the app path: "C:\Program Files\MyCompany\MyApp.exe"

However the Executable for an MSIX installed app is hidden I suspect its in "C:\Program Files\WindowsApps" but this folder is restricted and I can't get access even with admin permissions

There appears to be some data about the installation in C:\Users\MyUser\AppData\Local\Packages{myappguid} - but no executable files are available here.

So my question is simple: How can I launch an app from another program, when the app was installed using the MSIX application packager?


Solution

  • This turned out to be fairly simple.

    Edit your Package.appmanifest and add the following in the Application element

    <Extensions>
      <uap5:Extension Category="windows.appExecutionAlias">
        <uap5:AppExecutionAlias>
          <uap5:ExecutionAlias Alias="MyApp.exe"/>
        </uap5:AppExecutionAlias> 
      </uap5:Extension>
    </Extensions>
    

    And ensure this namespace is referenced at the top of the manifest file xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5" and is in the ignorable namespaces too.

    Rebuild and re-install the MSIX.

    Test at a new command-prompt - just type MyApp.exe - it should open the app.

    Now the second program can execute Process.Start("MyApp.exe") and it works.

    Reference: https://learn.microsoft.com/en-us/uwp/schemas/appxpackage/uapmanifestschema/element-uap5-extension