Experimenting with ClickOnce deployment
Experimenting with ClickOnce deployment
Join the DZone community and get the full member experience.Join For Free
A while ago Microsoft introduced a new deployment method for .NET applications called ClickOnce. In its core, it allows the developer to publish a desktop application somewhere on a remote server, so that the application installation and update process is easier and more robust. Yet another element that makes ClickOnce a preferred method for me is the one connected to administrative permissions – to install an application with ClickOnce, the current user doesn’t need admin rights on the local machine.
There are three deployment methods available when the developer decides to ship his application as a ClickOnce package:
• Installed from media (such as a CD or a USB stick)
• Installed from a remote server (be that a web server or a network share)
• Not installed at all on the client machine, but rather started remotely
Each of these methods has its benefits and drawbacks and in this article I am going to cover some particular aspects for each of them.
First of all, Microsoft Visual Studio 2005 or later is required to test ClickOnce deployment features, as it is a part of .NET Framework 2.0. ClickOnce deployment functionality is also available in Visual Studio Express editions.
In this article, I am not focusing on any particular application and I am not including any sample code. You can test the presented methods on an existing WPF, WinForms or console application.
Installing from media
This is the way to deploy ClickOnce applications if you, as the developer, want to distribute your application on physical media. You might ask in this case – why is this needed when a Windows Installer way to put things on a Windows machine can be used?
The answer is quite simple. One of the strong points for ClickOnce is the application update capabilities – when deploying a Windows Installer application, when there is an update available the application has to be completely re-installed. With ClickOnce, only the modified parts for the application are installed with the existing modules on the system.
Other reasons might include the absence of an internet connection on the client machine, although this scenario is much less likely to happen with the massive availability of broadband internet connection capabilities worldwide.
To start, in the Build menu (Visual Studio) select the Publish Project option:
Once clicked, you will be prompted to enter the location, where the package will be hosted. I am going to copy it on the local machine, so I am using a physical path on my hard disk:
Next, you will be prompted for the deployment method. Since I stored the package locally, the wizard automatically selected From a CD-ROM or DVD-ROM:
Leave it like that and proceed with the wizard. Next, you will be able to specify the path where the application will look for updates.
Of course, you can specify that the application will not check for updates if you are sure that this build will work fine for a period of time, but I would recommend having a web-server or local zone where updates are available. A UNC path or URL is required. The path can point to a network share.
Once you confirm the settings, the application will be published to the path you’ve shown and in the folder you pointed to you will be able to find a ClickOnce application manifest, a setup file and a folder that contains application files. Now, you can copy the package to physical media and distribute it.
Installed from a remote server
The process is the same as for an application that is distributed on physical media. The only difference is that the paths used are actual remote web server locations.
For example, I used a local IIS installation to host the application:
Note, that in order to use IIS, you need to run Visual Studio as an administrator (on Windows 7 and Vista).
You can also use your own FTP or web server.
Once you indicated the path, you need to specify how the application will run.
Here you have two choices – the application can be available for offline use (therefore, the user can have shortcuts to the app in the Start Menu and can manage it from the Add/Remove Programs applet in the Control Panel) or it can only be ran from a server (therefore, nothing is installed locally).
If you go with the first option, the application will be published on the server and the user will be able to install it just like the one targeting physical media.
Once the Install button is clicked, the standard installation popup window will be shown, asking whether the user agrees to install the application:
Note that the application is not signed, therefore there is a red security warning. Since this is your own application, you can click on Install, however when working with other tools, make sure that you know the origin of the application before installing it.
If you picked the second application deployment method (online-only), you will go through the same process, however once deployed, the application page will have a Run button instead of Install:
You will be able to run the application once you give the permission for it to do so. Note that if your default browser is not Internet Explorer, you will need at least Firefox with FFClickOnce in order to be able to work with hosted ClickOnce applications.
Note, that when using a hosted application, the functionality will be strictly limited, denying some system actions. This was introduced for security purposes and protects the user’s machine from unauthorized access to the local system and data.
Opinions expressed by DZone contributors are their own.