Walkthrough: Creating a Custom Installer for a ClickOnce Application

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at Walkthrough: Creating a Custom Installer for a ClickOnce Application.

Any ClickOnce application based on an .exe file can be silently installed and updated by a custom installer. A custom installer can implement custom user experience during installation, including custom dialog boxes for security and maintenance operations. To perform installation operations, the custom installer uses the InPlaceHostingManager class. This walkthrough demonstrates how to create a custom installer that silently installs a ClickOnce application.

To create a custom ClickOnce application installer

  1. In your ClickOnce application, add references to System.Deployment and System.Windows.Forms.

  2. Add a new class to your application and specify any name. This walkthrough uses the name MyInstaller.

  3. Add the following Imports or using statements to the top of your new class.

    No code example is currently available or this language may not be supported.
  4. Add the following methods to your class.

    These methods call InPlaceHostingManager methods to download the deployment manifest, assert appropriate permissions, ask the user for permission to install, and then download and install the application into the ClickOnce cache. A custom installer can specify that a ClickOnce application is pre-trusted, or can defer the trust decision to the AssertApplicationRequirements method call. This code pre-trusts the application.

    System_CAPS_ICON_note.jpg Note

    Permissions assigned by pre-trusting cannot exceed the permissions of the custom installer code.

    No code example is currently available or this language may not be supported.

  5. To attempt installation from your code, call the InstallApplication method. For example, if you named your class MyInstaller, you might call InstallApplication in the following way.

    No code example is currently available or this language may not be supported.

A ClickOnce application can also add custom update logic, including a custom user interface to show during the update process. For more information, see UpdateCheckInfo. A ClickOnce application can also suppress the standard Start menu entry, shortcut, and Add or Remove Programs entry by using a <customUX> element. For more information, see <entryPoint> Element and ShortcutAppId.

ClickOnce Application Manifest
<entryPoint> Element

Show: