I’m using some Power Pack 1 functionality in Disk Management v1.0.9.8, and making use of some of the SDK enhancements from Power Pack 2 in the upcoming Disk Management v1.1 release.

I’ve run into a few forum posts from users asking for help with Disk Management crashing, and sometimes it’s just because they have unknowingly installed Disk Management on a vanilla Windows Home Server with no Power Pack updates applied.

We can mitigate these issues in WiX with a very simple check, and then pop up a dialog box informing the user that they need to upgrade (or at least run Windows Update once in awhile).

Here’s the header of my current .wxs definition file:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Product
    Name="Disk Management for Windows Home Server"
    Id="*"
    Manufacturer="Sam Wood - Tentacle Software"
    Version="!(bind.FileVersion.ConsoleTab)"
    Language="1033">
    <Package
      Manufacturer="Sam Wood - Tentacle Software"
      InstallerVersion="200"
      Languages="1033"
      Compressed="yes" />

    <Media Id="1" Cabinet="DiskManagementForWHS.cab" EmbedCab="yes" />

    <Property Id="WHSLogo">1</Property>
	<Condition Message="[ProductName] requires Windows Home Server. For more information, please refer to the User Guide.">VersionNT = 502</Condition>

Pretty standard, and I’ve talked about this before. The lines we care about are the Property, defined as “WHSLogo” here (used by the WHS Console to make sure this is an Add-In), and the product version Condition. The condition has to evaluate as true, or we pop that error message and don’t let the install proceed.

We’re going to add a new property, and then evaluate that property in a new condition.

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Product
    Name="Disk Management for Windows Home Server"
    Id="*"
    Manufacturer="Sam Wood - Tentacle Software"
    Version="!(bind.FileVersion.ConsoleTab)"
    Language="1033">
    <Package
      Manufacturer="Sam Wood - Tentacle Software"
      InstallerVersion="200"
      Languages="1033"
      Compressed="yes" />

    <Media Id="1" Cabinet="DiskManagementForWHS.cab" EmbedCab="yes" />

    <Property Id="WHSLogo">1</Property>

    <Property Id="POWERPACKVERSION">
      <DirectorySearch Id="PowerPack" Path="[ProgramFilesFolder]\Windows Home Server\">
        <FileSearch Name="HomeServer.dll" MinVersion="6.0.2029.0"/>
      </DirectorySearch>
    </Property>

    <Condition Message="[ProductName] requires Windows Home Server. For more information, please refer to the User Guide.">VersionNT = 502</Condition>
    <Condition Message="[ProductName] requires Windows Home Server Power Pack 2 or higher."><![CDATA[Installed OR POWERPACKVERSION]]></Condition>

Our new POWERPACKVERSION property performs a directory and file search, and locates HomeServer.dll. We have a minimum version of 6.0.2029.0 defined, which means our property will only be populated if both HomeServer.dll exists and is greater than our minimum version number.

Due to some potential localization issues, you should set your minimum version number to one less than the number you actually need. In Power Pack 2, HomeServer.dll is 6.0.2030.0, so I’ve set my MinVersion property to 6.0.2029.0.

You can see that I’ve also added another Condition, below the product version check. We’re actually checking two properties here, Installed and our POWERPACKVERSION. If either of these properties are true, we allow the installation (or uninstallation) to proceed.

That Installed check is key – our conditions are evaluated during install, but also during uninstall of the add-in. If the conditions don’t evaluate to true, the install or uninstall will be blocked. We want to avoid blocking the uninstallation if the user has rolled back a Power Pack update, so we let the operation continue even though the file version may be incorrect.

What does this look like in practice? Here’s a screenshot of the error message popping up and blocking the Add-In installation from completing:

image

The version numbers are easy to find. Just right-click your target assembly, in this case HomeServer.dll, and choose Properties – the version number you want will be on the Details tab in Windows 7, or the Version tab in Windows Server 2003.

You can add other checks, as well. There have been a few poorly-built Add-In installers that unintentionally remove key WHS system files when the Add-In is uninstalled. To save support headaches later, we can check that the key assemblies we depend on exist prior to install.

A couple of examples:

    <Property Id="HOMESERVERCONTROLS">
      <DirectorySearch Id="HomeServerControls" Path="[ProgramFilesFolder]\Windows Home Server\">
        <FileSearch Name="HomeServerControls.dll"/>
      </DirectorySearch>
    </Property>

    <Property Id="INTEROP">
      <DirectorySearch Id="Interop" Path="[ProgramFilesFolder]\Windows Home Server\">
        <FileSearch Name="Microsoft.HomeServer.SDK.Interop.v1.dll"/>
      </DirectorySearch>
    </Property>

    <Condition Message="[ProductName] requires one or more Windows Home Server files that are missing (HomeServerControls.dll)."><![CDATA[Installed OR HOMESERVERCONTROLS]]></Condition>
    <Condition Message="[ProductName] requires one or more Windows Home Server files that are missing (Microsoft.HomeServer.SDK.Interop.v1.dll)."><![CDATA[Installed OR INTEROP]]></Condition>

Adding these checks to your WiX installer takes only a few seconds, and adds just that extra bit of polish to your Add-In.

posted on Thursday, December 10, 2009 11:06 PM | Filed Under [ Windows Home Server Development ]

Comments

No comments posted yet.

Post Comment

Title *
Name *
Email
Url
Comment *  
Remember me
Please add 8 and 6 and type the answer here:

Search

Site Sections

Recent Posts

Archives

Post Categories

WHS Add-In Tutorial

WHS Blogs

WHS Development