|
The sample application is configured to update itself, there are other options
for configuring application updates, which would run out of the application
itself for example, but for illustration purposes I chose this model.
This article will use the BITS downloader, which copies the files from an HTTP
Server. You can always write your woen downloader by deriving from the
IDownloader interface.
Configuration on the client:
Our working directory for our sample application will be
: d:\projects\selfupdater\SayHello\bin\debug\
The name of the application that we are going to update
dynamically is SayHello.
Files necessary in the working directory of the
application that will be updated:
| Filename |
Use |
| Appstart.exe |
Will be used to instantiate the downloaded files. |
| AppStart.exe.config |
Config file for appstart.exe - will configure where the app direcotry is and
the exe to instantiate - also contains the version info of the last download |
| Microsoft.ApplicationBlocks.ApplicationUpdater.dll |
The update technology lies in here |
| Microsoft.ApplicationBlocks.ApplicationUpdater.Interfaces.dll |
ApplicationUpdater references this |
| Microsoft.ApplicationBlocks.ExceptionManagement.dll |
ApplicationUpdater references this |
| Microsoft.ApplicationBlocks.ExceptionManagement.Interfaces.dll |
ApplicationUpdater references this |
| SayHello.exe |
The application that will be updated |
| SayHello.exe.config |
The config file for the application that will be updated
This config file will contain all the config settings for the download
procedure
|
The configuration of the appstart.exe.config file:
<appStart>
<ClientApplicationInfo>
<appFolderName>D:\projects\selfupdater\SayHello\bin\debug\2.0.0.0</appFolderName>
<appExeName>SayHello.Exe</appExeName>
<installedVersion>2.0.0.0</installedVersion>
<lastUpdated>2004-03-10T15:50:14.7737744+02:00</lastUpdated>
</ClientApplicationInfo>
</appStart>
The configuration of the app.config file:
The logfile location can be configured here, this is helpful
in tracking the progress.
<logListener
logPath="D:\projects\selfupdater\SayHello\bin\debug\UpdaterLog.txt" />
If validation is enabled it is important that the key that
is generated with the manifest utility is stored in the <key>
section.
<key>
<RSAKeyValue>
<Modulus>nxq8YYpiEb/RFMFaEP1Q+cU62lfyct0cIk/q0xT9M+aPoBVsSEA3zC6cUoWNXSLnfbqqE
7qiWdP3u7p+JDWLy6sKZPZX6CZX0XvaVDeyrVmB0tXoDkYX
RwzcYjZiE94xDYpoi8VlPyb8OCarVC9Go
HW3KquRfm6XfpILhj/dC0s=</Modulus> <Exponent>AQAB</Exponent>
</RSAKeyValue>
</key>
The application section configures the download
locations.
In the client section we will have the locations of:
-
baseDir: The base directory / working directory
-
xmlFile: The location of the AppStart.exe file
-
tempDir: The location of the temp direcotry in which the
files will be downloaded
In the server section we will have the locations of:
-
xmlFile: The URL to use to get the server manifest xml
file on the server
-
xmlFileDest: The local directory to download the server
manifest xml file to
<application name="SayHello" useValidation="true">
<client>
<baseDir>D:\projects\selfupdater\SayHello\bin\debug\</baseDir>
<xmlFile>D:\projects\selfupdater\SayHello\bin\debug\AppStart.exe.config</xmlFile>
<tempDir>D:\projects\selfupdater\SayHello\bin\debug\newFiles</tempDir>
</client>
<server>
<xmlFile>http://localhost/sayHelloUpdate/ServerManifest.xml</xmlFile>
<xmlFileDest>D:\projects\selfupdater\SayHello\bin\debug\ServerManifest.xml</xmlFileDest>
<maxWaitXmlFile>60000</maxWaitXmlFile>
</server>
</application>
Configuration of the server:
The server needs a publicly available location where the
files will be located.
Follow these steps to create this location and to publish the correct files for
the update:
-
In IIS, create a virtual directory called sayHelloUpdate
on the server - this corresponds to the value we have in the config file on the
client
-
Point this directory to a directory on the server where
you want to store the files
-
In this directory you should have a servermanifest.xml
file - this can be called something else - but we have configured the client
for this name
-
Before creating the servermanifest file you have to create
a directory with a name of the available version number. In our case we want to
upgrade to version 2.0.0.0, so we have to create a directory in the virtual
folder called 2.0.0.0.
Into this folder we then copy the new versions of the file, any other
dependencies of the files that we publish should be copied in here too.
-
Now that the files are located in the correct
download directory we can proceed in creating the servermanifest file. Open the
ManifestUtility application which is provided with the application block.
See figure 1.2 for the correct settings. Here's a rundown:
-
Update files folder: The directory where the files are
located in - not the root directory, but the directory named after the version
(2.0.0.0)
-
Update location: The url to get to the same directory as
in step 1
-
Version: The version number of the available version, in
our case 2.0.0.0
-
Validator assembly: The path to the
Microsoft.ApplicationBlocks.ApplicationUpdater.dll assembly
-
Validator class: in our case choose the RSA validator
-
We don't have a post processot, so don't use theis section
-
For the key you have to choose the Generate Keys option in
the file menu, save the keys in a safe place. With the open file dialogue,
browse to the saved location, choose the privatekey.xml file.
You have to open the app.config file (client config) and insert the contents of
the newly created publickKey.xml in the key section of the config file.
-
Click on the "Create Manifest" button
-
Note: Only the files that are in the
directory at the moment of creation of the server manifest file will be
downloaded, the other files will be ignored
-
The IIS directory also needs some prepping:
-
Open the internet services manager
-
Right click on the sayHelloUpdate virtual folder
-
Click on properties
-
In the virtual directory tab, ensure that all these items
are checked: Script source access, Read, Write and Direcotry browsing
-
In the same tab, click the "Configuration" button.
-
In the app mappings tab, look for a .config entry in the
list of application mappings
-
Highlight it
-
Click on "Remove"
Figure 1.2
|