Quantcast
Channel: C# City » enterprise library
Viewing all articles
Browse latest Browse all 3

Sending Multiple Updates Through the Updater Block

$
0
0

In a previous post, we discussed the basics of Microsoft’s Updater block from their Enterprise Library: that clients connect to a server, pull XML files describing updates (files to update and an execution script/task to execute), grab those updates passively via BITS, and then download and execute updates.

As promised, this post will describe how to include multiple updates in a single manifest file.

The key here is really to understand that manifest files and refer to other manifest files. This means we have a master/index manifest file, which links all the update manifests.

Conceptually, you can have recursive manifests, nested manifests, or a tree/graph of manifests (with an unlimited amount of nesting, as far as I can tell). And in terms of performance, only new manifests are downloaded, so you don’t need to worry about a performance hit.

Our previous manifest looked like this:


<manifest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" manifestId="{9DBCD243-0479-4dd2-883B-8DA46FC3FCA9}" mandatory="False" xmlns="urn:schemas-microsoft-com:PAG:updater-application-block:v2:manifest">
  <description>New software update</description>
  <application applicationId="{225E1AD7-8ABA-432f-A942-24BACA556850}">
  <!-- Path relative to <location /> of the app to launch for this update -->
    <entryPoint file="SimpleApplication\1.0.0.0\SimpleApplication.exe" parameters="" />
  <!-- Local path to store the downloadad file. Creates if necessary. -->
    <location>C:\Temp\Updater\</location>
  </application>
  <files base="http://localhost/MyAwesomeUpdateServer" hashComparison="No">
  <!-- Place on the remote server where we store the file -->
    <file source="SimpleApplication\1.0.0.0\SimpleApplication.exe" transient="No" />
  </files>
  <activation>
    <tasks>
      <task type="Microsoft.ApplicationBlocks.Updater.ActivationProcessors.ApplicationDeployProcessor, Microsoft.ApplicationBlocks.Updater.ActivationProcessors" name="ApplicationDeployProcessor" />
    </tasks>
  </activation>
</manifest>

Let’s rip out and stub out tasks and files, and instead, put them into a child manifest called update1.xml. This file will look like:


<manifest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" manifestId="{9DBCD243-0479-4dd2-883B-8DA46FC3FCA9}" mandatory="False" xmlns="urn:schemas-microsoft-com:PAG:updater-application-block:v2:manifest">
  <description>New software update</description>
  <application applicationId="{225E1AD7-8ABA-432f-A942-24BACA556850}">
  <!-- Path relative to <location /> of the app to launch for this update -->
    <entryPoint file="SimpleApplication\1.0.0.0\SimpleApplication.exe" parameters="" />
  <!-- Local path to store the downloadad file. Creates if necessary. -->
    <location>C:\Temp\Updater\</location>
  </application>
  <files base="http://localhost/MyAwesomeUpdateServer" hashComparison="No">
  <!-- Place on the remote server where we store the file -->
    <file source="SimpleApplication\1.0.0.0\SimpleApplication.exe" transient="No" />
  </files>
  <activation>
    <tasks>
      <task type="Microsoft.ApplicationBlocks.Updater.ActivationProcessors.ApplicationDeployProcessor, Microsoft.ApplicationBlocks.Updater.ActivationProcessors" name="ApplicationDeployProcessor" />
    </tasks>
  </activation>
</manifest>

Now that we have encapsulated our update into its own manifest, let’s update the original manifest to reference this one:


<manifest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" manifestId="{11BCD243-0379-4cd2-883A-8D946FC3FBA1}" mandatory="False" xmlns="urn:schemas-microsoft-com:PAG:updater-application-block:v2:manifest">
  <description>New software update</description>
  <application applicationId="{215E1AD7-9ABA-432f-A952-24BABA556850}">  
    <entryPoint file="" parameters="" />
    <location>C:\Temp\Updater\</location>
  </application>
  <files base="http://localhost/MyAwesomeUpdateServer" hashComparison="No" />
  <includedManifests>
    <manifest location="update1.xml" manifestId="{11BCD243-0379-4cd2-883A-8D946FC3FBA1}" />
  </includedManifests>
</manifest>

You’ll notice the <includedManifests> section, which references our update1.xml manifest. Great!

That’s it! If you wanted to add another update, simply create an update2.xml (or whatever you want to call it), and add another <manifest ... /> to your master/index manifest file to reference it.

One caveat: The Updater block uses manifest IDs to tell if a manifest has changed. The updater is smart enough to know if the original file has additional referenced files, even if the ID hasn’t changed. So you just need to add the new manifest, and you’re golden.

Simple as that!


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images