MSIX Tweaker

Use the MSIXTweaker.exe command line MSIX editor tool to automate repetitive MSIX editing operations without using the MSIX GUI Editor.

Usage

  • MSIXTweaker.exe /Update <msix_package_path> *<commands> - updates an MSIX package according to the specifed commands. *Commands can be chained on the same line one after the other and they will be applied accordingly if their syntax is correct. See all supported commands and their syntax in the section below.
  • MSIXTweaker.exe /BatchFileUpdate <msix_package_path> <batch_file_path> [-nofail] - updates an MSIX package according to the commands sequence from the batch file. The -nofail switch will not stop subsequent commands if one command from the batch file fails. The first characters in the file must be ;twc;, please see the example below for details.
  • MSIXTweaker.exe /help [<command_name>] - shows the syntax for the specified command. If the <command_name> switch is omitted, the syntax for all supported commands will be listed.

Supported Commands

Files

  • /Add-File <file_path_in_msix_package> <file_source_path> - adds a file from the disk in the specified location from the MSIX package. This command also updates FilesystemMetadata.xml and Content_Types.xml manifest files.
  • /Update-File <file_path_in_msix_package> <file_source_path> - updates a file from the MSIX package with the specified file from the disk.
  • /Del-File <file_path_in_msix_package> - deletes a file from the specified location in the MSIX package. This command also updates FilesystemMetadata.xml and Content_Types.xml manifest files.
  • /Add-ScriptFile <file_source_path> - adds a script file from the disk in the MSIX package.
  • /Update-ScriptFile <script_file_name> <file_source_path> - updates a script file from the MSIX package with the specified script file from the disk.
  • /Del-ScriptFile <script_file_name> - deletes a script file from the MSIX package.

Registry

  • /Set-RegistryKey <registry_key_path> [-virtualizationlevel <merge | overwrite | deleted>] - adds a new registry key to the specified registry location in the MSIX package. The optional switch -virtualizationlevel can determine how the virtual application sees the registry key and it can be set for an existing registry key.

TipYou can use the above command for example when you want to virtualize an existing key (with all its children) from the target machine as deleted.

  • /Del-RegistryKey <registry_key_path> - deletes a registry key from the specified registry location in the MSIX package.
  • /Set-RegistryValue <registry_key_path> [-valuename <registry_value_name>] [-type <sz | expandsz | dword | multisz | binary>] [-value <registry_value>] [-pathvariable] - creates or updates a registry value in the MSIX package.

TipIf you need to create a multiple line registry value (REG_MULTI_SZ) use the %0A%0D separator in the value field (e.g. -value "first line%0A%0Dsecond line")

  • /Del-RegistryValue <registry_key_path> <registry_value_name> - removes a registry value from the MSIX package.

Note<registry_key_path> must point to an absolute path in the MSIX registry hive.

Digital Signature

  • /Sign <sign_command_options> - signs an MSIX package

The <sign_command_options> are identical with the Microsoft SigntTool.exe sign command options.

NoteThe subject of the digital certificate is not automatically extracted, therefore signing a package requires the creation of a batch file to handle multiple commands.

Exmple of batch files used for signing an MSIX package:

;twc

Set-ElementAttribute AppxManifest.xml -xpath "appx:Identity" -attributename "Publisher"  -attributevalue "CN=Test-sha2, OU=Test, O=Test, E=someemail@myemail.com"
Sign /f "C:\digital-sign-no-pass.pfx" /fd SHA256 /t "http://timestamp.digicert.com"
      

Manifest

  • /Set-NodeText <AppxManifest.xml | FilesystemMetadata.xml | PackageHistory.xml | StreamMap.xml | [Content_Types].xml> -xpath <xml_xpath_expression> [-nodetext <xml_node_text>] - updates an existing node from the specified XML file.
  • /New-Element <AppxManifest.xml | FilesystemMetadata.xml | PackageHistory.xml | StreamMap.xml | [Content_Types].xml> [-xpath <xml_xpath_expression>] -elementname <xml_element_name> -namespaceURI <xml_namespaceuri> [-elementtext <xml_node_text>] [-createifnotexist] - creates or updates an XML element in the specified XML file.
  • /Set-ElementAttribute <AppxManifest.xml | FilesystemMetadata.xml | PackageHistory.xml | StreamMap.xml | [Content_Types].xml> [-xpath <xml_xpath_expression>] -attributename <xml_attribute_name> [-attributevalue <xml_attribute_value>] - creates or updates an attribute for an existing XML element.
  • /Del-SingleNode <AppxManifest.xml | FilesystemMetadata.xml | PackageHistory.xml | StreamMap.xml | [Content_Types].xml> -xpath <xml_xpath_expression> - removes a single node from the specified manifest file.
  • /Del-Nodes <AppxManifest.xml | FilesystemMetadata.xml | PackageHistory.xml | StreamMap.xml | [Content_Types].xml> -xpath <xml_xpath_expression> - removes multiple nodes from the specified manifest file.
  • /TransformManifest <AppxManifest.xml | FilesystemMetadata.xml | PackageHistory.xml | StreamMap.xml | [Content_Types].xml> <xsl_transform_file_path> [*<-param_name param_value>] - applies an XSL transform to the specified manifest XML file. *You can specify several <-param_name param_value> pairs.
  • /Update-PackageIdentity -packageid <identity_package_id> -versionid <identity_version_id> -version <identity_version> - updates package identity details. Instead of values you can also type in auto. This will generate new IDs or increment the version with 1.
  • /Update-PackageHistory -packagingengine <packaging_engine_name> -sequencerversion <sequencer_version> - updates the package history log. The default values are MSIXTweaker and its version. You can specify for example Sequencer and its version.

Examples

The following command searches for the element "Types" in the root of "[Content_Types].xml", then creates a new "Default Extension" child element with a value of "pdf".

MSIXTweaker.exe /Update "C:\Work\MSIX packages\Sample.msix" /New-Element "[Content_Types].xml" -xpath "/Types" -elementname "Default Extension" -namespaceURI "http://schemas.openxmlformats.org/package/2006/content-types" -elementtext "pdf" -createifnotexist

This is an example of a batch commands file:

;twc;

Del-SingleNode FilesystemMetadata.xml -xpath "appv:StaticDependencies"
New-Element FilesystemMetadata.xml -elementname "StaticDependencies" -namespaceURI "http://schemas.microsoft.com/appv/2010/FilesystemMetadata" -createifnotexist
New-Element FilesystemMetadata.xml -xpath "appv:StaticDependencies" -elementname "Executable" -namespaceURI "http://schemas.microsoft.com/appv/2010/FilesystemMetadata"
Set-ElementAttribute FilesystemMetadata.xml -xpath "appv:StaticDependencies/appv:Executable[last()]" -attributename "Long" -attributevalue "Root\VFS\ProgramFilesX86\CodeMeter\Runtime\bin\CodeMeterCC.exe"
New-Element FilesystemMetadata.xml -xpath "appv:StaticDependencies/appv:Executable[last()]" -elementname "Entry" -namespaceURI "http://schemas.microsoft.com/appv/2010/FilesystemMetadata"
Set-ElementAttribute FilesystemMetadata.xml -xpath "appv:StaticDependencies/appv:Executable[last()]/appv:Entry[last()]" -attributename "Long" -attributevalue "Root\VFS\SystemX86\WibuCm32.dll"