How do you build an MSIX package from the command line

My end goal is to be able to run a Powershell install script in a VM and capture all the changes it makes into a MSIX package. I can do this manually without issue using the MSIX Packaging Tool wizard, but I have a lot of apps to package and some of them update frequently, so I would like to get something automated going.

I have tried using the batch conversion script with the following settings in entry.ps1:

$virtualMachines = @(
    @{ Name = "MSIX Packaging Tool Environment"; Credential = $credential }
)

$remoteMachines = @(
)

$conversionsParameters = @(
    @{
        InstallerPath = "Cricut Design Space.msi";
        PackageName = "CricutDesignSpace";
        PackageDisplayName = "Cricut Design Space";
        PublisherName = "CN=Cricut";
        PublisherDisplayName = "Cricut";
    }
)

Which just tells me all jobs have finished and produces no MSIX files.

I have also tried manually creating this template:

<MsixPackagingToolTemplate
  xmlns="http://schemas.microsoft.com/appx/msixpackagingtool/template/2018"
  xmlns:mptv2="http://schemas.microsoft.com/msix/msixpackagingtool/template/1904">
<Installer
  Path="L:\Work\scratch\batch-msix-builder\Cricut Design Space.msi"
  Arguments="" />
<VirtualMachine Name="MSIX Packaging Tool Environment" Username="user" />
<SaveLocation PackagePath="L:\Work\scratch\batch-msix-builder" />
<PackageInformation
  PackageName="CricutDesignSpace"
  PackageDisplayName="CricutDesignSpace"
  PublisherName="CN=Cricut"
  PublisherDisplayName="Cricut"
  Version="5.9.8.0" />
</PackageInformation>
</MsixPackagingToolTemplate>

and running it with

MsixPackagingTool.exe create-package --template "L:\Work\scratch\batch-msix-builder\template.xml" --virtualMachinePassword "REDACTED"

This causes a console window to open for a fraction of a second and immediately close. I have even tried this on a fresh install of windows to see if it was something with my computer.


I have been working on this for more than a day, and of course as soon as I post online I discovered what was going wrong.

The main issue was MsixPackagingTool.exe doesn't seem to work when I let it prompt for elevation as opposed to explicitly running it from an administrative PowerShell window. Additionally I had some malformed XML. Once I started running from an elevated command prompt I was able to actually see the errors output by MsixPackagingTool.exe.