Deploying Separate User/Site Configurations with ClickOnce, Page 3
In the example, as shown in Figure 7, the form's background color has been changed to blue.
Figure 7: Modifying the form
Navigating back to the project's properties and the 'Publish' tab, you'll notice that the Publish Version has automatically incremented after the first publish.
Figure 8: Publishing an update
Click the "Publish Now" button to create the update package for the 126.96.36.199 version of the application. This time, if the publish page comes up, you can close it; you will be updating the application, not installing it from the installation location.
Copy all the files found in the publishing folder location to the update location. You'll notice in the Application Files folder that there is a new folder for the 188.8.131.52 version of the application.
Figure 9: The application update files
If you haven't already done so, close the application that was launched from the original installation. Navigate to the Start menu and launch the application. You'll notice a brief period of "searching" while the application checks for a newer version. Once it finds that version 184.108.40.206 is available, you'll be presented with the Update Available dialog. Click OK. The new version will be installed and launched automatically.
Figure 10: Your updated ClickOnce application
In the scenario of deploying different sets of configuration options, you can set up multiple installation locations with different configuration files, publish each version of the application with the respective installation location, and set all the update locations to the single update directory. If you use the default configuration settings framework, ClickOnce will manage the merging of configuration settings when updating to new versions of the application. Read up on this topic to get a better understanding of how this works.
Method 2: Configurating Applications Based on URL Parameters
The second method for deploying separate configurations is to use URL parameters to set up the configuration in code during the first installation of the application. When a ClickOnce installation is accessed via a URL on a network or the Internet, you can configure the application to accept parameters via the URL, parse the parameters in the application's code, and store settings in the application configuration file. This method is superior to the first one in that you do not have to manage multiple installation packages. Only one installation is required and you can use the same directory location for updates to the application.
To follow the demonstration below, you will need to set up the following:
- Create the folder: "C:\ClickOnceDeployment"
- Configure "ClickOnceDeployment" with IIS to be a virtual directory with the same name
Create a new Windows Forms project using Visual Studio (2005 or later). On the default form, change the text property to "Main Form". To configure the application to read the parameters passed to the application during deployment, open up the Code view of the default form and add the following using statements:
using System.Collections.Specialized; using System.Deployment.Application; using System.Web;
Page 3 of 5