Create an MSIX package with MSIX Core from source code

MSIX Core brings MSIX deployment to select previous versions of Windows. You can leverage the MSIX Core installer to create an application using ClickOnce. This will allow your users to download a setup.exe and install the MSIX app through the MSIX Core installer.

Host your app on a web server

To get your app ready for bootstrapping with the MSIX Core installer, you’ll need to host your app package on a web server. This section provides details about how to set up a web app on Azure, Internet Information Services (IIS), and Amazon Web Services (AWS).

Azure

To use this option you must have an Azure subscription. To obtain one, see the Azure account page.

Create an Azure Web App

To get started go to the Azure portal page and follow these steps:

  1. Click Create a Resource.
  2. Click Web and select Web App.
  3. Under Instance Details, create a unique app name and select the appropriate settings for your app. For example, you will need to choose between Code or Docker Container and the Runtime Stack. Otherwise, leave everything else default.
  4. Click Create and finish the wizard.

Host the app package and the web page

  1. After you create the web app, select the app.
  2. Under Development Tools, click App Service Editor.
  3. In the editor, there is a default hostingstart.html file. Right-click in the empty space of File Explorer and select Upload Files to begin uploading your app packages.
  4. Right-click in the empty space of the File Explorer panel again and select New Files to create a new file. Name the file what you want your default HTML page to be.

Configure the web app for app package MIME types

Add a new file named Web.config to the web app. Open the Web.config file and add the following XML to the file.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <!--This is to allow the web server to serve resources with the appropriate file extensions-->
    <staticContent>
      <mimeMap fileExtension=".appx" mimeType="application/appx" />
      <mimeMap fileExtension=".msix" mimeType="application/msix" />
    </staticContent>
  </system.webServer>
</configuration>

Internet Information Services (IIS)

IIS is an optional Windows feature. To install IIS:

  1. Click Start and search for Turn Windows features on or off.
  2. Select Internet Information Services.
  3. Also make sure you install ASP.NET 4.5 or greater. In the Windows Features dialog, expand Internet Information Services -> World Wide Web Services -> Application Development Features, and select a version of ASP.NET that is greater than or equal to ASP.NET 4.5.
  4. Click OK to begin the installation.

Visual Studio 2017 (or a later version) and Web Development Tools are required. If you already have Visual Studio 2017 or a later version installed, make sure you have the ASP.NET and Web development workloads installed. Otherwise, install Visual Studio from here.

Build a web app

Start Visual Studio as an administrator and create a new Visual C# Web Application project with an empty project template.

Configure IIS with your Web app

  1. In Solution Explorer, right-click on the root project and select Properties.
  2. In properties, select the Web tab.
  3. In the Servers section, choose Local IIS from the dropdown menu and click Create Virtual Directory.

Add the app package to the web application

Add the app package that you want to distribute to the web application:

  1. In Solution Explorer, right-click the project node.
  2. Select Add -> New Folder and name the folder packages.
  3. To add app packages to the folder, right-click the packages folder and select Add -> Existing Item. Browse to the app package location.

Create a web page

Create an HTML page or any other web app as required per your needs. Add the link of your new setup.exe.

Configure the web app for app package MIME types

Open the Web.config file from the solution explorer and add the following XML within the <configuration> element.

<system.webServer>
  <!--This is to allow the web server to serve resources with the appropriate file extensions-->
  <staticContent>
    <mimeMap fileExtension=".appx" mimeType="application/appx" />
    <mimeMap fileExtension=".msix" mimeType="application/msix" />
  </staticContent>
</system.webServer>

Amazon Web Services (AWS)

To use this option you must have an AWS membership. For more information, see AWS account details.

Create an Amazon S3 bucket and upload your MSIX packages and web pages

Amazon Simple Storage Service (S3) is an AWS offering for collecting, storing and analyzing data. S3 buckets are a convenient way to host Windows 10 app packages and web pages for distribution.

  1. Log in to AWS. Under Services find S3.
  2. Select Create bucket and enter a Bucket name for your website. Follow the dialog prompts for setting properties and permissions. To ensure that your Windows 10 app can be distributed from your website, enable Read and Write permissions for your bucket and select Grant public read access to this bucket. Click Create bucket to finish this step.
  3. When you are finished, upload your MSIX packages and web pages to the S3 bucket.

Configure the web app for app package MIME types

Using a web service interface like S3 browser to add a new Default HTTP Headers.

  1. Navigate to Tools and select Default HTTP Headers.
  2. In the Default HTTP Headers dialog, click Add.
  3. In the Add New Default HTTP Headers dialog, specify the bucket name, file name, header name, and header value, and then click Add new header.
    • Bucket name: msix-packages
    • File name: *.msix
    • Header name: Content-Type
    • Header value: application/msix

Note

 AWS have some strict guidelines you will have to follow. For example, Bucket names are required to be unique and therefore if you are using the example above, you will need to change the Bucket name.

Use the MSIX Core installer to build the ClickOnce application

Find your application application ClickOnce setup.exe. This is refering to the clone of the Git project, build and publish it via Visual Studio project.

Run URL command to create new setup.exe

Make sure you have followed the instructions to clone, build and publish the MSIX Core solution in Visual Studio. For reference, the GitHub project can be found here

Navigate to the directory where you published the setup.exe file and then run this command:

.\setup.exe -url=<location of your msix in the webservice>

For example

.\setup.exe -url="https://appinstallerdemo.azurewebsites.net/MSIXCore/msixmgrWrapper.application?https://appinstallerdemo.azurewebsites.net/MSIXCore/notepadplus.msix#"

Sign the application

Because the previous step created a new setup.exe, you will need to sign the app again to verify that you're a trusted publisher of the application and to establish the integrity of the application. You can use the SignTool and provide your certificate.

Distribute the application to your users

You can now point to the new setup.exe with a link or download button on their website. MSIX Core is targeted towards users on Windows 10, version 1703 and earlier. The App Installer is the ideal installation process for MSIX packages on Windows 1709 or a later version. App Installer optimizes for disk space on the consumer side and can directly install apps from HTTP locations. MSIX Core will detect if a consumer is on Windows 1709 or a later version and redirect them to App Installer.

On Microsoft Edge, you can call the getHostEnvironmentValue() method and the os-build field in the return value will specify the OS version of the user. From there, you can then prompt the installation process to use MSIX Core (for Windows 10, version 1703 and earlier) or App Installer (for Windows 10, version 1709 and later).

User experience

Users simply download and run the setup.exe from the developer’s webpage.

  • If the MSIX Core installer is not yet installed when the user runs setup.exe, the user sees the ClickOnce prompt and they click Install to install the MSIX Core installer. The installer automatically launches and shows the install screen for the MSIX package specified in the developer’s query string so the users can install the app.
  • If the MSIX Core installer is already installed when the user runs setup.exe, the MSIX Core installer automatically launches and shows the install screen for the MSIX package specified in the query string for users to install the app.