MSIX Applications: Handle Prerequisites by Declaring Dependencies in MSIX

Written by Alex Marin · August 6th, 2021


In the packaging industry, we're used to using application dependencies very often. And with the transition from MSI to MSIX, we have more options to declare and handle them.

In MSI, we use Prerequisites to chain multiple dependencies -- which means that the installation would continue only if the product was found in the chain, otherwise, it would fail.

NoteFor more details about Prerequisites, have a look at our FAQ.

We're happy to see that Microsoft took this up a notch with MSIX, offering more alternatives to help packagers manage dependencies.

In this article, we will first understand what is an MSIX dependency, how it works and how you can define it within the Advanced Installer project.

Try Advanced Installer for free through our 30-days full featured trial. Download it from here.

What is a Package Dependency and how to add it into the MSIX Manifest?

A PackageDependency helps to establish package dependencies and incompatibilities that may slow down your application's installation process.

You will find the <Dependencies> element in every AppxManifest.xml from MSIX.

The <Dependencies> element usually contains the minimum required OS version and the maximum tested OS version needed for your application to install.

NoteKeep in mind that your installation will fail if your minimum OS version declared in the MSIX manifest is higher than the OS version of your machine.

This is how an OS version dependency looks in our AppManifest:

<TargetDeviceFamily MaxVersionTested="10.0.19041.0" MinVersion="10.0.17763.0" Name="Windows.Desktop"/>

If your MSIX package needs a specific prerequisite (dependency) to install, you have the option to add it in the <Dependencies> element as a <PackageDependency> child element.

Can you make a dependency package optional?

Microsoft also offers the possibility to make a dependency package optional. If this option is enabled, you can install the main MSIX package even if the dependency is not found.

Take into consideration that this flag is set to “false” by default. So, if you add a dependency like the one in the example below, the installation will fail since the application (in our case Caphyon.SampleApplication) will not be installed on the machine.

<TargetDeviceFamily MaxVersionTested="10.0.19041.0" MinVersion="10.0.17763.0" Name="Windows.Desktop"/>
<PackageDependency MinVersion="" Name="Caphyon.SampleApplication" Publisher="CN=TestCert_2020-3-25_14-56-53"/>

To make a dependency optional, we can use the uap6:Optional attribute which can be placed in the AppxManifest like:

<TargetDeviceFamily MaxVersionTested="10.0.19041.0" MinVersion="10.0.17763.0" Name="Windows.Desktop"/>
<PackageDependency MinVersion="" Name="Caphyon.SampleApplication" uap6:Optional="true" Publisher="CN=TestCert_2020-3-25_14-56-53"/>

How do dependencies work?

Now that we understand what dependencies are and how they are added into the MSIX manifest -- let's see how they work and how they differ from MSI dependencies.

First, let's recap how MSIX packages can be installed:

  1. Via the Microsoft Store.
  2. Via a website: MSIX package.
  3. Via a website: .appinstaller file.

Let’s have a look at the scenarios to see how dependencies behave in each case.

1. Installing MSIX Dependencies via Microsoft Store

When you publish your package to the Microsoft Store, make sure to also publish the dependencies for your application. This way, when a user installs your application using the Microsoft Store, dependencies are also automatically downloaded and installed.

NoteThe automatic download and installation of a dependency also happens if the dependency has already been published before in the Microsoft Store.

When the dependency is a third-party application (packaged as an MSIX), you should either ask the vendor to publish your dependency or add it as an optional dependency in your MSIX manifest and then ask users to manually install it from the third-party vendor website.

2. Installing MSIX Dependencies Via a website: MSIX package

Microsoft offers the MS-AppInstaller protocol which can be easily added to any website.

However, if you add a dependency to your MSIX package and publish it to your website, you will be prompted to an error message.

This happens because the package does not know where the dependency is located as seen below:

Installation fails

To fix this issue, you should place the dependency as optional in your main package, and advise users on your website to first install the dependency and then the main package.

If that is not enough, you can use .appinstaller files as an alternative, as we will see below.

3. Installing MSIX Dependencies Via .appinstaller files

In our how to enable auto-updates for your MSIX packages without publishing them to the Microsoft Store article. We can see that the creation of an .appinstaller file is required, and the installation of the MSIX package must be done via that appinstaller file.

NoteYou can create .appinstaller files with a single click using Advanced Installer’s GUI. Learn more about that in our how-to page: How to create an AppInstaller file for an MSIX package?

Once an .appinstaller file is created, you can add the <Dependencies> element to it and specify the location of the dependency:

<Package Name="Microsoft.VCLibs.140.00" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" Version="14.0.24605.0" ProcessorArchitecture="x86" Uri="" />
<Package Name="Microsoft.VCLibs.140.00" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" Version="14.0.24605.0" ProcessorArchitecture="x64" Uri="" />

When the <Dependencies> element is added in the .appinstaller file, you will notice that the dependencies will be installed first from the specified location, followed by the main application.

Defining Dependencies with Advanced Installer

The scenarios we've gone through may seem a little bit tricky when it comes to declaring dependencies inside an MSIX package. Luckily, Advanced Installer’s GUI makes this step effortless.

To add a simple MSIX dependency, simply follow these steps:

  1. Create a new MSIX package, or open your existing project;
  2. Navigate to the Dependencies Page;
  3. Click on Add Dependency in the upper right corner;
  4. Select your MSIX package.
Add msix dependency

Yep, it's as simple as that. You just added your dependency.

Remember: You can leave the optional to false (make the dependency required) or you can change it to true.

If you want to also create the .appinstaller file to contain the dependency, it’s even easier.

Follow the steps presented here, and when you click build, Advanced Installer will automatically detect that you have a dependency added in the package. It will then add it to the .appinstaller file.

No need for extra configurations.

We hope you got a clear overview of how dependencies work in MSIX and how you can add them using one of the options presented above or using the Advanced Installer’s GUI.

Let us know your preferred method to handle dependencies!

Subscribe to Our Newsletter

Sign up for free and be the first to receive the latest news, videos, exclusive How-Tos, and guides from Advanced Installer.