Menu Close

Creating VHD for MSIX app attach (appattach)

This article is about the usage of command line interface. More information about CLI usage and how to get started can be found here: Command Line Interface (CLI) Reference

This command creates a VHD file for MSIX app attach purposes (requires MSIX Hero 1.0.14 or newer).

Note: This command must be executed by a local administrator. Otherwise, an error will be returned when trying to execute it.

The command has the following syntax:

MSIXHeroCLI.exe appattach --directory <path-where-to-extract> --package <package-to-be-converted> [--name <filename>] [--size <maximum-vhd-size>] [--createScripts] [--extractCert] [--fileType <vhd|vhdx|cim>]

You can also use shorter form of arguments.

MSIXHeroCLI.exe appattach -d <path-where-to-extract> -p <package-to-be-converted> [-n <filename>] [-s <maximum-vhd-size>] [-c] [-e]

For example:

MSIXHeroCLI.exe appattach --directory "c:\vhd" --package "c:\download\msix-hero-1.0.0.0.msix" --createScripts
MSIXHeroCLI.exe appattach --directory "c:\vhd" --package "c:\download\msix-hero-1.0.0.0.msix" --createScripts --extractCert
MSIXHeroCLI.exe appattach --directory "c:\vhd" --package "c:\download\msix-hero-1.0.0.0.msix" --name "msix-hero" --size 100
MSIXHeroCLI.exe appattach -d "c:\vhd" -p "c:\download\msix-hero-1.0.0.0.msix" -c --fileType cim
MSIXHeroCLI.exe appattach -d "c:\vhd" -p "c:\download\msix-hero-1.0.0.0.msix" -c -e
MSIXHeroCLI.exe appattach -d "c:\vhd" -p "c:\download\msix-hero-1.0.0.0.msix" -n "msix-hero" -s 100

Both parameters --directory (-d) and --package (-p) are required.

Parameter --package supports multiple values, separated by space.

The following parameters are optional:

  • –createScripts (shorthand -c)
    When defined, sample scripts for app attach (registering, staging, de-staging and de-registering) will be created and saved together in the directory, specified by the --directory (-d) switch. Four scripts will be created: stage.ps1, register.ps1, deregister.ps1 and destage.ps1.
  • –fileType <vhd|vhdx|cim>
    Declares the output format. The default value is VHD. This parameter is available in MSIX Hero 2.2 and newer.
  • –extractCert (shorthand -e)
    When defined, the digital certificate will be extracted from the MSIX package and put in the directory, specified by the --directory (-d) switch. The name of the file will be the same as the name of the MSIX file or as the value of the optional parameter --name (-n).
  • –size <#> (shorthand -s <#>)
    Specifies the maximum dynamic size of VHD disk. If not set, MSIX Hero uses an optimal size, which ensures that the package fits and has a reasonable buffer. The size specified by this parameter should be expressed in megabytes. If you provide a value lower than the total size of expanded files, an error will be returned.
  • –name <X> (shorthand -n <X>)
    By default, the names of the VHD file and the extracted certificate file (if switch --extractCert or -e was used) are equal to the name of the MSIX package. By providing this optional parameter you can choose the name you want.

The result of execution is an VHD (expanded package) and depending on the option other files. The program returns the following exit codes:

Exit codeMeaning
0VHD has been created.
1Unspecified error.
2-10Invalid parameters or other command-line related errors.
11The program must be started by a local administrator.
<any other>Any other error or win32 error code.