January 2009 Blog Posts

It looks like our friends at Microsoft have finally pushed .NET 3.5 as an important update to all Windows Server 2003 machines; luckily for us, Windows Home Server fits into that category too!

Here’s the proof (screenshot from my production Windows Home Server, that definitely did not have .NET 3.5 installed prior to this update):

whs-dotnet-3.5-installed

It’ll be interesting to see if we get a spike in the number of Add-Ins built with .NET 3.5 in the next few months. Bring on the W*F Add-Ins.

WGS have posted the results of their Reader Awards 2008 competition.

Windows Home Server Disk Management was beaten out this year by Kentdome TechnologiesGrid Junction Add-In. Of course, I can’t complain; I use Grid Junction on a number of Windows Home Servers myself!

So, congratulations to Alexander on winning this year! We’ll have to be content with second place.

Using WiX to install and start a Windows Service as part of your Add-In install is fairly easy. The only thing you really have to watch out for is the KeyPath value for your service executable; it has to be set to yes, while all other file KeyPaths must be set to no.

Make sure you also use your own GUID values for UpgradeCode and Component ID values.

This code works with the latest WiX 3.0 weekly build.

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Product
    Name="Windows Home Server Disk Management Add-In"
    Id="*"
    UpgradeCode="{EB6B8302-C06E-4bec-ADAC-932C68A3A98D}"
    Manufacturer="Sam Wood - Tentacle Software"
    Version="1.1.0.0"
    Language="1033">
    <Package
      Manufacturer="Sam Wood - Tentacle Software"
      InstallerVersion="200"
      Languages="1033"
      Compressed="yes" />

    <Media Id="1" Cabinet="WHSDiskManagement.1.1.0.0.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>

    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder" Name="PFiles">
        <Directory Id="WHS" Name="Windows Home Server">
          <Component Id="HomeServerConsoleTab.DiskMgt" Guid="{908B7199-DE2A-4dc6-A8D0-27A5AE444FEA}">
            <File Id="HomeServerConsoleTab.DiskMgt.dll" Name="HomeServerConsoleTab.DiskMgt.dll" Source="..\HomeServerConsoleTab.DiskMgt\bin\Release\HomeServerConsoleTab.DiskMgt.dll" Vital="yes" KeyPath="no" DiskId="1"/>
            <File Id="DiskMgt.Common.dll" Name="DiskMgt.Common.dll" Source="..\DiskMgt.Remotable\bin\Release\DiskMgt.Common.dll" Vital="yes" KeyPath="no" DiskId="1"/>
            <File Id="DiskMgt.Service.exe" Name="DiskMgt.Service.exe" Source="..\DiskMgt.Service\bin\Release\DiskMgt.Service.exe" Vital="yes" KeyPath="yes" DiskId="1"/>
            <ServiceInstall
              Id="ServiceInstaller"
              Type="ownProcess"
              Vital="yes"
              Name="DiskManagement"
              DisplayName="Windows Home Server Disk Management"
              Description="Monitoring and management service for Windows Home Server Disk Management Add-In"
              Start="auto"
              Account="LocalSystem" 
              ErrorControl="ignore" 
              Interactive="no"
              >
              <ServiceDependency Id="QSM"/>
              <ServiceDependency Id="pdl"/>
              <ServiceDependency Id="WHSTransportService"/>
            </ServiceInstall>
            <ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="DiskManagement" Wait="yes" />
		  </Component>
	    </Directory>
	  </Directory>
	</Directory>

	<Feature Id="ProductFeature" Title="WHSDiskManagement" Level="1">
      <ComponentRef Id="HomeServerConsoleTab.DiskMgt" />
	</Feature>
  </Product>
</Wix>

ServiceDependency values are the real names for the services your code depends on. You can find the Service Name by opening services.msc and checking the properties for the specific service.

The ServiceControl node allows you to start and stop services during install and uninstall.

In the example above, I’m controlling a service called DiskManagement (the service I’m installing in the parent ServiceInstall node, but it could be any service). The service is started after the MSI package has been installed, stopped (if it’s started, to allow me to overwrite or delete the service’s files) at the beginning of both install and uninstall operations, and removed at the end of an uninstall operation.

The Service Control Id value is just an identifier that you can use to refer to this specific ServiceControl node in other places in the XML.

If you want to use extended character sets (for localization into different languages, usually) in the various display and description fields, you’ll need to set the xml encoding value and Product Codepage appropriately. I’ve also set the Product Language and Package Languages to German in this example:

<?xml version="1.0" encoding="Windows-1252"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Product
    Name="Windows Home Server Datenträger-Verwaltung"
    Id="*"
    UpgradeCode="{EB6B8302-C06E-4bec-ADAC-932C68A3A98D}"
    Codepage="1252"
    Manufacturer="Sam Wood - Tentacle Software"
    Version="1.1.0.0"
    Language="1031">
    <Package
      Manufacturer="Sam Wood - Tentacle Software"
      InstallerVersion="200"
      Languages="1031"
      Compressed="yes" />

There’s some good documentation on the rest of the options (ownProcess, Start type, Account etc.) in the WiX help files that get installed along with the WiX binaries. It’s not the most friendly set of technical docs I’ve seen, but it does give detailed descriptions of the individual configuration elements.

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">    
  <Product    
    Name="My First Add-In"   
    Id="*"   
    UpgradeCode="{1a7c55f0-ceed-11dd-ad8b-0800200c9a66}"   
    Manufacturer="Sam Wood - Tentacle Software"   
    Version="0.0.0.1"   
    Language="1033">    
    <Package    
      Manufacturer="Sam Wood - Tentacle Software"   
      InstallerVersion="200"   
      Languages="1033"   
      Compressed="yes" />     
</Wix>

Ok, I think I like this better. Easy to copy and paste, and it looks pretty slick now that I’ve got the pre-wrapping resolved. Not sure if I love the idea of javascript running through the page and updating styles post-load, but I think the end result is worth it.

What I’m not going to like is having to go back through all the tutorials and update the code snippets!

Let me know your opinion.

Search

Site Sections

Recent Posts

Archives

Post Categories

WHS Add-In Tutorial

WHS Blogs

WHS Development