Clickonce deployment of winform programs

Source: Internet
Author: User

Use clickonce to publish winformProgramThis will make the application deployment very convenient.ArticleThis section describes the problems that may occur when using and deploying clickonce.

Content Overview
    1. Clickonce Introduction
    2. Publish site creation
    3. Configure the clickonce Program
    4. Release a clickonce package
    5. Problem makeup
    6. One disadvantage of clickonce
1. clickonce Introduction

Microsoft officially explained clickonce: clickonce is a deployment technology that you can use to create windows-based self-update applications, in addition, installation and running of such applications require minimal user interaction.

Using clickonce mainly solves several problems in program deployment:

    • It is difficult to update the application.Use Microsoft Windows installer to deploy the application. Each time you update an application, you can install the update (MSP file) and apply it to the installed product. Use clickonce to deploy the application, updates are automatically provided. Only the changed application is downloaded, and the complete and updated application is re-installed from the new parallel folder.
    • Impact on users' computers.When using Windows Installer for deployment, applications usually rely on shared components, which may lead to version conflicts. When using clickonce for deployment, each application is independent, it does not interfere with other applications.
    • Security permissions.Windows Installer deployment requires administrator permissions and only allows users to install the program. clickonce deployment allows non-administrator users to install the application and only grantCodeAccess security permissions.

To put it simply, the programs deployed in clickonce can be automatically updated, almost green, and the execution permission of the program has a finer granularity.

The following figure shows the basic architecture of clickonce (image source)

2. Create a publishing site

Let's take a look at the Release Interface after the winform program is deployed using clickonce. Just click Install to download the program from the deployed server and install and run it.

Therefore, the establishment of the site is involved here, and a site is created on the web server for publishing a new clickonce package.

Before creating a site, check whether the two components are enabled.

After it is enabled, create a site and select an empty directory created by yourself as the path. The settings of other web servers will not be described here.

3. Configure the clickonce Program

Right-click the winform project to open the property page and configure relevant compilation properties. For detailed configuration of compilation properties, see the previous article about winform compilation and configuration.

Switch to the release tag, as shown in.

In the release directory, you can select the Web, FTP, and file path modes. Here we can fill in the empty web site we configured previously.

In the installation mode, two installation modes are supported: online or offline availability. Generally, users can use published applications even when disconnected.

Click "program file" to open the dialog box.

You can select which files can be published to clickonce to publish them to the client.

By default, the file package compiled by the program is included in the clickonce package. Here, you may encounter a problem: how to pack other files, such as instructions, into the deployment package automatically after they are updated in the project.

For example, if we have installed readme.txt in the project, this file will not be published when we release a new package by default.

If the secondary node is to be accessed, right-click readme.txt to open the attribute and configure the two values.

In the required components dialog box, clickonce automatically analyzes the required components. Of course, you can also select the required components by yourself, you can also configure to download components from the supplier's page, from our own release path, or from other paths.

One of the biggest features of a program released using clickonce is that it can be automatically updated, that is, when a new version is found on the publishing server, it will be automatically updated before running, of course, the updated policy can also be configured. The "Update" dialog box is displayed.

You can choose to update the program before or after the program starts.

Or check for updates and update programs according to the interval.

Or force the user to update to a specific version.

You can also configure the update package in another path.

In the "properties" dialog box, you can set the basic attributes of a release.

Such as the publisher, Suite name, program name, etc. Some settings here will affect the information on the deployment page and the user's installed directory.

Of course, you can also set it here, for example, whether to insert the CD package into the CD installation package and whether to create a shortcut on the desktop after installation, you can click to set what you need.

You can also set whether to automatically increase the version number or set it by yourself. The version number setting here is best in accordance with the version number usage principle. Otherwise, the maintenance will be messy and good habits will often help you get twice the result with half the effort.

4. Release a clickonce package

Before release, let's talk about two more things: code access security and program signature.

    • Code access security:Clickonce applications are restricted by code access security constraints in. NET Framework to help restrict code access to protected resources and operation permissions. Therefore, it is very important to understand the meaning of code access security and write clickonce applications accordingly. Your applications can use full trust or partial areas (such as the internet region and Intranet region) to restrict access permissions.
    • Program signature:Clickonce uses a certificate to verify the authenticity of the application issuer, and uses the certificate to sign the application and deployment list to prove that the file has not been tampered. Signature is an optional step, which makes it easier to change the application file after the configuration is generated. However, without a signature list, it is difficult to ensure that the application installer is not tampered with when it is under a man-in-the-middle security attack. For this reason, we recommend that you sign the Application List and deployment list to help protect your application.

For more information about this part, see the protection Application Section in msdn.

Then click the publish button. After the release is successful, ie will automatically open the published page. You only need to send the published address to the customer who needs to install the program to deploy the program easily.

5. Problem Addendum
    • For signature expiration problems, refer to Xu haibiao's article: Solve the clickonce signature expiration problem.
    • For the clickonce trusted file size issue, modify the Registry HKEY_CURRENT_USER \ Software \ Classes \ Software \ Microsoft \ Windows \ CurrentVersion \ deployment
      Make a dwrod value of onlineappquotainkb.
6. One disadvantage of clickonce

When clickonce is used, I think the biggest drawback is that users are not allowed to choose to install it. By default, it will be placed in a series of Hidden directories under the local settings directory in the Documents and Settings folder of the current user.

The original intention is to provide a location for application storage. clickonce takes over the physical installation task of the application from the user. By independently saving all applications and their different versions of datasets and data files, caching also helps isolate applications.

This restricts the deployment path of clickonce, which greatly limits the selection and use of clickonce. I hope Microsoft can improve this function.

I hope you don't feel cool when you see this shortcoming, just like when I found this shortcoming, just select as needed. :)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.