Shell Context Menu Support in MSIX Packaging
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.
The 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.
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.