Skip to content

Instantly share code, notes, and snippets.

@mkoertgen
Created April 19, 2016 16:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save mkoertgen/5712d780f8bdb086d01d3bdebd5b1a84 to your computer and use it in GitHub Desktop.
Save mkoertgen/5712d780f8bdb086d01d3bdebd5b1a84 to your computer and use it in GitHub Desktop.
Patching ClickOnce Manifests

Patching ClickOnce Manifests

The following examples take on the example of deploying the fictional .NET application app.exe. NOTE: With ClickOnce you can only deploy .NET applications out of the box. Ho, cf. How can I deploy a non .net application with ClickOnce?.

Creating a ClickOnce deployment for any .NET application

Create the application manifest from the build output (binaries)

mage -n Application -t app\app.exe.manifest -fd app

Then create the deployment manifest

mage -n Deployment -t app.application -appm app\app.exe.manifest

IMPORTANT: The .NET app should be created without manifest, cf Walkthrough: Manually Deploying a ClickOnce Application (MSDN)

Updating publisher and/or product name

mage -u app.application -pub <Publisher> -n <AppName>

If either value contains whitespace wrap in quotes like this

mage -u app.application -pub "My cool Publisher" -n "My cool app"

Updating install mode to online only

    mage -u app.application -i false

Updating install mode to online & offline again

mage -u app.application -i true

This means installing a start menu entry and optionally a desktop shortcut. *NOTE: For -i true you need to also set publisher and product name.

Activating or deactivating a desktop shortcut

To make for a desktop shortcut include the attribute createDesktopShortcut="true" in the deployment element of the deployment manifest

<deployment ... co.v1:createDesktopShortcut="true">

NOTE: This assumes the xml-namespace xmlns:co.v1="urn:schemas-microsoft-com:clickonce.v1" is declared in the xml-root element assembly.

To disable desktop shortcut, set to false or simply remove the attribute as this is the default.

Updating desktop shortcut to a custom icon

mage -u app\app.exe.manifest -if custom.ico

The specified icon should be visible as the Desktop shortcut and in the Taskbar. When running the app directly after installation or download (default), the taskbar icon may still be a generic icon. This is a known ClickOnce bug. Just restart the app to see the updated icon.

NOTE: For the custom.ico to be used it needs to be deployed with the application. For a new icon file, place it in the app directory and update the application manifest. Easiest is to populate from directory like this

mage -u app\app.exe.manifest -if custom.ico -fd app

NOTE: For some odd reason ClickOnce cannot use alpha channel in 32bit icon files. Instead it uses the lower left pixel value as a heuristic for the transparent pixel. So be sure to add a 1 pixel extra boundary. For more details see How to fix your ClickOnce icons.

Updating the icon in Programs & Features

Customizing the icon in Control Panel\Programs\Programs and Features is not directly supported in ClickOnce. ClickOnce will always show a generic ClickOnce icon. To customize the icon you need to change the registry.

Here is an example on how to do this in code on first start ClickOnce: Setting a custom icon in 'Add/Remove Programs'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment