-
Notifications
You must be signed in to change notification settings - Fork 28
Adding a CLI packaging guide #185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,166 @@ | ||
| # Packaging a CLI Executable as MSIX | ||
|
|
||
| This guide walks you through packaging an existing command-line executable as an MSIX package for distribution via Windows Package Manager (winget), the Microsoft Store, or direct distribution. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - An existing CLI executable (`.exe`) that you want to package | ||
| - Windows 10 version 1809 or later | ||
|
|
||
|
|
||
| ## Steps | ||
|
|
||
| ### 1. Organize Your CLI Application | ||
|
|
||
| Place your CLI executable and any dependencies in a dedicated folder. This folder will contain all files that should be included in your MSIX package. | ||
|
|
||
| ```powershell | ||
| mkdir MyCliPackage | ||
| cd MyCliPackage | ||
| # Copy your CLI executable and dependencies here | ||
| ``` | ||
|
|
||
| ### 2. Install WinApp CLI | ||
|
|
||
| The quickest way to get started is to install WinApp CLI via Windows Package Manager: | ||
|
|
||
| ```powershell | ||
| winget install microsoft.winappcli | ||
| ``` | ||
|
|
||
| ### 3. Generate the appxmanifest.xml | ||
|
|
||
| Generate a base appxmanifest.xml and required assets for your CLI executable: | ||
|
|
||
| ```powershell | ||
| winapp manifest generate --executable .\yourcli.exe | ||
| ``` | ||
|
|
||
| This command creates an `appxmanifest.xml` file in the current directory with default values populated from your executable. | ||
|
|
||
| ### 4. Configure the Manifest | ||
|
|
||
| You'll need to edit the generated `appxmanifest.xml` to: | ||
| - Add an execution alias so users can run your CLI from any directory | ||
| - Hide the app from the Start menu app list | ||
| - Update application details to match your CLI | ||
|
|
||
| #### 4.1 Add Required Namespace | ||
|
|
||
| Add the `uap5` namespace to the `Package` element if it's not already present: | ||
|
|
||
| ```xml | ||
| <Package | ||
| xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" | ||
| ... | ||
| xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" | ||
| xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5" | ||
| xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" | ||
| IgnorableNamespaces="uap uap5 rescap"> | ||
| ``` | ||
|
|
||
| #### 4.2 Configure the Application Element | ||
|
|
||
| In the `<uap:VisualElements>` element, add `AppListEntry="none"` to prevent the app from appearing in the Start menu: | ||
|
|
||
| ```xml | ||
| <uap:VisualElements | ||
| DisplayName="YourApp" | ||
| Description="My Application" | ||
| BackgroundColor="transparent" | ||
| Square150x150Logo="Assets\Square150x150Logo.png" | ||
| Square44x44Logo="Assets\Square44x44Logo.png" | ||
| AppListEntry="none"> | ||
| </uap:VisualElements> | ||
| ``` | ||
|
|
||
| #### 4.3 Add Execution Alias Extension | ||
|
|
||
| Add the execution alias extension within the `<Application>` element (after `<uap:VisualElements>`): | ||
|
|
||
| ```xml | ||
| <Extensions> | ||
| <uap5:Extension Category="windows.appExecutionAlias"> | ||
| <uap5:AppExecutionAlias> | ||
| <uap5:ExecutionAlias Alias="yourcli.exe" /> | ||
| </uap5:AppExecutionAlias> | ||
| </uap5:Extension> | ||
| </Extensions> | ||
| ``` | ||
|
|
||
| Replace `yourcli.exe` with the desired command name for your CLI. Once a user installs the MSIX, they will be able to invoke your CLI with this command. | ||
|
|
||
| #### 4.4 Update Application Metadata | ||
|
|
||
| Update the following fields to match your CLI application: | ||
|
|
||
| - **Identity**: Update `Name`, `Publisher`, and `Version` | ||
| ```xml | ||
| <Identity | ||
| Name="YourCompany.YourCLI" | ||
| Publisher="CN=Your Company" | ||
| Version="1.0.0.0" /> | ||
| ``` | ||
|
|
||
| - **Properties**: Update display name, publisher display name, and description | ||
| ```xml | ||
| <Properties> | ||
| <DisplayName>Your CLI Tool</DisplayName> | ||
| <PublisherDisplayName>Your Company</PublisherDisplayName> | ||
| <Description>Description of your CLI tool</Description> | ||
| <Logo>Assets\StoreLogo.png</Logo> | ||
| </Properties> | ||
| ``` | ||
|
|
||
| - **VisualElements**: Update display name and asset references | ||
| ```xml | ||
| <uap:VisualElements | ||
| DisplayName="Your CLI Tool" | ||
| Description="Description of your CLI tool" | ||
| BackgroundColor="transparent" | ||
| Square150x150Logo="Assets\Square150x150Logo.png" | ||
| Square44x44Logo="Assets\Square44x44Logo.png"> | ||
| <uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" /> | ||
| <uap:SplashScreen Image="Assets\SplashScreen.png" /> | ||
| </uap:VisualElements> | ||
| ``` | ||
|
|
||
| **Note**: You should also add proper icon assets to an `Assets` folder in your package directory. While the app won't appear in the Start menu, icons are still required for Store submission and may appear in other contexts. | ||
|
|
||
| ### 5. (Optional) Generate a Development Certificate | ||
|
|
||
| For local testing and distribution outside the Microsoft Store, you'll need to sign your MSIX package with a certificate. | ||
|
|
||
| Generate a development certificate: | ||
|
|
||
| ```powershell | ||
| # Navigate to a location outside your CLI folder (e.g., your home directory) | ||
| cd ~ | ||
| winapp cert generate | ||
| ``` | ||
|
|
||
| This creates a `devcert.pfx` file. To trust this certificate on your development machine, install it (requires administrator privileges): | ||
|
|
||
| ```powershell | ||
| # Run PowerShell as Administrator | ||
| winapp cert install | ||
| ``` | ||
|
|
||
| **Important**: Keep your development certificate outside the folder containing your CLI executable to avoid accidentally including it in the package. | ||
|
|
||
| ### 6. Package Your CLI | ||
|
|
||
| Now you're ready to create the MSIX package: | ||
|
|
||
| ```powershell | ||
| # Run from outside CLI folder | ||
| # Package with dev certificate (for local testing/distribution) | ||
| winapp pack .\MyCliPackage --cert path\to\devcert.pfx | ||
| ``` | ||
|
|
||
| This creates an `.msix` file in the current directory | ||
|
|
||
| ### Tips: | ||
| 1. Once you are ready for distribution, you can sign your MSIX with a code signing certificate from a Certificate Authority so your users don't have to install a self-signed certificate | ||
| 2. The Microsoft Store will sign the MSIX for you, no need to sign before submission. | ||
| 3. You might need to create multiple MSIX packages, one for each architecture you support (x64, Arm64) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know it was that easy to accidentally include devcert.pfx in the package. Should we add logic to winappCLI to detect this and block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good idea. Should we block though or just warn? Let me create an issue where we can discuss