Shell Context Menu Support in MSIX Packaging

Written by Horatiu Vladasel · November 16th, 2023

What is Context Menu?

The Context Menu is undeniably one of the most useful shell extensions in Windows. This menu appears when you right-click on an object, like a file, folder, or icon, in Windows Explorer or File Explorer.

Context Menu offers a quick and easy way to access various actions and options for the selected object.

Available context menu options vary based on the object's type and the software installed on your system. Beyond the standard options Windows provides, some applications add their own to enhance functionality.In this article, we'll delve into the nuances of the Context Menu, particularly focusing on its integration and support within MSIX packaging.

Let’s explore how this functionality is implemented, using the popular file archiver, 7Zip, as a practical example.

MSIX Support for Context Menu

Starting with MSIX Packaging Tool version 1.2022.11, legacy ContextMenu interfaces for shell extensions are automatically detected and added into the Appxmanifest file. This applies for both context menu or drag and drop handlers.

ImportantThe Context Menu requires Windows 11 21H2 and later in order to work as expected.

According to Microsoft documentation, for Windows Shell to recognize and register the extension, the Appxmanifest file must include specific namespaces:

- Windows.comserver extension.

<com:Extension Category="windows.comServer">
	<com:ComServer>
    	<com:SurrogateServer DisplayName="<display-name-for-the-com-server>">
        	<com:Class Id="<GUID-for-the-com-server>" Path="<path-to-the-com-server-or-dll>" ThreadingModel="STA" />
    	</com:SurrogateServer>
	</com:ComServer>
</com:Extension>

- Desktop9 namespace – here you can have either a FileExplorerClassicContextMenuHandler or a FileExplorerClassicDragDropContextMenuHandler extension.

<desktop9:Extension Category="windows.fileExplorerClassicContextMenuHandler">
	<desktop9:FileExplorerClassicContextMenuHandler>
    	<desktop9:ExtensionHandler Type="*" Clsid="<GUID-for-the-com-server>" />
    	<desktop9:ExtensionHandler Type=".txt" Clsid="<GUID-for-the-com-server>" />
    	<desktop9:ExtensionHandler Type="Directory" Clsid="<GUID-for-the-com-server>" />
	</desktop9:FileExplorerClassicContextMenuHandler>
</desktop9:Extension>
<desktop9:Extension Category="windows.fileExplorerClassicDragDropContextMenuHandler">
	<desktop9:FileExplorerClassicDragDropContextMenuHandler>
    	<desktop9:ExtensionHandler Type="Directory" Clsid="<GUID-for-the-com-server>" />
    	<desktop9:ExtensionHandler Type="Drive" Clsid="<GUID-for-the-com-server>" />
	</desktop9:FileExplorerClassicDragDropContextMenuHandler>
</desktop9:Extension>

Additionally, the “MaxVersionTested” should be set to a value greater than “10.0.21300.0”.

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

Now that we know what Context Menu is and how it works, let’s give it a try. And what more suitable application we could have other than 7Zip.

7Zip Context Menu using MSIX Packaging Tool

We downloaded 7Zip version 22.01 and repackaged it on a Windows 11, 22H2 build using MSIX Packaging Tool 1.2023.319.0.

After generating the 7Zip MSIX package, a peek into its Appxmanifest file reveals that it includes the following extensions:

  • windows.fileExplorerClassicContextMenuHandler,
  • windows.fileExplorerClassicDragDropContextMenuHandler,
  • windows.comserver.

Additionally, the “MaxVersionTested” in the file is updated to “10.0.22000.1”.

7Zip MSIX Appxmanifest file

7Zip Context Menu using Advanced Installer

Advanced Installer also supports Shell Context Menus, declared within the “Declaration Page” under Application Declarations.

For this 7Zip application, you need to specify:

- File Explorer Classic Context Menu Handlers.

Classic Context Menu extension handlers

- File Explorer Classic Drag Drop Context Menu Handlers.

Classic drag drop Context Menu handlers

Discover the power of smooth integration and enhanced functionality with Advanced Installer; start your 30-day free trial now and elevate your packaging experience!

Context Menu on Windows 11

After installing the 7Zip MSIX package on a Windows 11 machine (version 21H2 or later), the Context Menu appears as expected.

For those not familiar with Windows 11, Windows 11 implements the right-click context menu differently compared to Windows 10, for both native Win32 apps and MSIX packages.

To access the full context menu, right click on the file and select “Show more options”.

Show more options

Only then you are able to see the newly added Context Menu item.

Newly added Context Menu item

Conclusion

In enterprise environments and beyond, the Context Menu is often an essential functionality. MSIX's default support for Shell Context Menu marks a significant advancement in MSIX packaging and deployment.

Written by
See author's page
Horatiu Vladasel

Horatiu is a Software Packager/Sequencer with over 10 years experience, who has worked as a Software Packager at IBM and is currently offering software packaging services to companies such as BT or Nationwide.

Comments: