Skip to content

Create Custom Package

ikas edited this page Sep 29, 2024 · 7 revisions

Overview

Modify the package, then repackage and sign it

  1. Tools, use Microsoft's official MSIX Packaging Tool
  2. Certificate for signing, create a self-signed certificate
  3. Package to be modified, use ContextMenuCustom-CMC_ANY-X

Steps

Tools

Download and install MSIX Packaging Tool https://learn.microsoft.com/en-us/windows/msix/packaging-tool/package-editor

App package

ContextMenuCustom-CMC_ANY-XXX
Min Version : 5.0.0.0

Download form github release or github actions

Certificate

detail: https://learn.microsoft.com/en-us/windows/msix/package/create-certificate-package-signing

create certificate

#-Subject "CN=CMC-DEV" 
#-FriendlyName "cmc-dev"
New-SelfSignedCertificate -Type Custom -Subject "CN=CMC-DEV" -KeyUsage DigitalSignature -FriendlyName "cmc-dev" -CertStoreLocation "Cert:\CurrentUser\My" -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.3", "2.5.29.19={text}")

output

Thumbprint                                Subject
----------                                -------
79F6CCA60D36A57C8672197D0DA0B6071A40AEB0  CN=CMC-DEV

export certificate as pfx

# -String xxxxxxxxxx password
# -cert Cert:\CurrentUser\My\{Thumbprint} Thumbprint
# -FilePath f:/test.pfx path
$password = ConvertTo-SecureString -String xxxxxxxxxx -Force -AsPlainText
Export-PfxCertificate -cert "Cert:\CurrentUser\My\79F6CCA60D36A57C8672197D0DA0B6071A40AEB0" -FilePath f:/test.pfx -Password $password

Edit Package

  1. Open MSIX Packaging Tool,Click Package editor
  2. Select ContextMenuCustom-CMC_ANY-XXX ,Then Click Open
  3. Signing preference,Select sign with a cert(.pfx), select pfx file
  4. Manifest file Click Open file, Will open Manifest file, we need modify it (See below for details)
  5. Change Version, plus 1

Manifest Description

<?xml version="1.0" encoding="utf-8"?>

<Package >

<!-- 1. Name : uuid, must be unique  -->	
  <Identity  Name="852637cb-5c5e-4695-93cd-d2b0ca79f6de" Publisher="CN=CMC-DEV" Version="5.0.5.0" />

  <Properties>
<!-- 2. DisplayName PublisherDisplayName-->	
    <DisplayName>Custom Context Menu (Any)</DisplayName>
    <PublisherDisplayName>touchwp</PublisherDisplayName>
    <Logo>Images\StoreLogo.png</Logo>
  </Properties>

  <Applications>
    <Application Id="App">
<!-- 3. DisplayName PublisherDisplayName -->	
      <uap:VisualElements
        DisplayName="Custom Context Menu (Any)"
        Description="Custom Context Menu (Any) For Win11"
         />
      </uap:VisualElements>
		<Extensions>
			<desktop4:Extension Category="windows.fileExplorerContextMenus">
				<desktop4:FileExplorerContextMenus>
<!-- 4. Clsid 9DD7188B-41FA-4C01-BFB2-F82DC1521DAD   must be unique  -->	
					<desktop5:ItemType Type="Directory"  >
						<desktop5:Verb Id="CustomMenu" Clsid="9DD7188B-41FA-4C01-BFB2-F82DC1521DAD" />
					</desktop5:ItemType>
					<desktop5:ItemType Type=".png"  >
						<desktop5:Verb Id="CustomMenu" Clsid="9DD7188B-41FA-4C01-BFB2-F82DC1521DAD" />
					</desktop5:ItemType>
					<desktop5:ItemType Type=".jpeg"  >
						<desktop5:Verb Id="CustomMenu" Clsid="9DD7188B-41FA-4C01-BFB2-F82DC1521DAD" />
					</desktop5:ItemType>
					<desktop5:ItemType Type="Directory\Background">
						<desktop5:Verb Id="CustomMenu" Clsid="9DD7188B-41FA-4C01-BFB2-F82DC1521DAD" />
					</desktop5:ItemType>
				</desktop4:FileExplorerContextMenus>
			</desktop4:Extension>
			<com:Extension Category="windows.comServer">
				<com:ComServer>
					<com:SurrogateServer  DisplayName="Custome Context Menu (Any)">
<!-- 5. Id 9DD7188B-41FA-4C01-BFB2-F82DC1521DAD  must same as 4  -->	
						<com:Class Id="9DD7188B-41FA-4C01-BFB2-F82DC1521DAD" Path="ContextMenuCustomHost.dll" ThreadingModel="STA"/>
					</com:SurrogateServer>
				</com:ComServer>
			</com:Extension>

		</Extensions>
	</Application>

</Applications>

</Package>


Identity

Name="852637cb-5c5e-4695-93cd-d2b0ca79f6de" Replace with a new guid

com:Class Id

Clsid 9DD7188B-41FA-4C01-BFB2-F82DC1521DA, Replace with a new guid

File Type

support *, .xxx, Directory, Directory\Background

<desktop5:ItemType Type="Directory"  >
	<desktop5:Verb Id="CustomMenu" Clsid="9DD7188B-41FA-4C01-BFB2-F82DC1521DAD" />
</desktop5:ItemType>
<desktop5:ItemType Type=".png"  >
	<desktop5:Verb Id="CustomMenu" Clsid="9DD7188B-41FA-4C01-BFB2-F82DC1521DAD" />
</desktop5:ItemType>
<desktop5:ItemType Type=".jpeg"  >
	<desktop5:Verb Id="CustomMenu" Clsid="9DD7188B-41FA-4C01-BFB2-F82DC1521DAD" />
</desktop5:ItemType>
Clone this wiki locally