Announcing the CAB Installer SDK

It seems that every time I work on a project I get near the end and have to deal with actual deployment of the application and things go south.  Let’s face it, Microsoft’s wceload application sucks – and that’s being generous. It’s limited, it’s got no object model, and it’s behavior has changed over time without any of those changes being documented.

In a recent project I was trying to silently install an application to a directory that would change depending on the target hardware becasue different devices have their storage media named differently.  I wanted to do this without changing or having multiple CAB files, since the application was no different. Achieving this with wceload, I am convinced, is utterly impossible so I put on my reverse-engineering hat, downloaded the CAB spec (cabfmt.doc), and went to work.  Now, a few month later, and with the help of Alex Feinman, we’ve created a new product called the Windows CE CAB Installer SDK.  In addition to a new product, we went with a new pricing model as well.

The SDK comes with full source,  unit and integration tests designed for running under mstest, samples for generating compressed and uncompressed CAB (the SDK supports both), a template for creating custom installer DLLs and both VB and C# examples of using the SDK.

The main workhorse of the SDK is the WinCEInstallerFIle class, which looks like this:




An example of a custom installer looks like this (just to give you a flavor of how it works):


using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using OpenNETCF.Compression.CAB;
using OpenNETCF.Net.MTConnect.Components;
using OpenNETCF.Net.MTConnect.DataItems;

namespace System.Runtime.CompilerServices
{
public class ExtensionAttribute : Attribute
{
}
}
namespace ONCFInstall
{
public delegate void FileProgressHandler(int progressPercent);
public static class Extensions
{
public static string Find(this List list, string findString)
{
foreach (string file in list)
{
if (string.Compare(file, findString, true) == 0)
{
return file;
}
}
return null;
}
}
public class CustomCABInstaller : WinCEInstallerFile
{
private int m_fileCount = 0;
private CommandLineArgs m_args;
public event FileProgressHandler FileProgress;
public CustomCABInstaller(string cabFileName, CommandLineArgs args)
: base(cabFileName)
{
m_args = args;
SkipFileNames = m_args.SkipFiles ?? new List();
PathStringReplacements = m_args.PathStringReplacements ?? new Dictionary();
SkipOSVersionCheck = m_args.SkipOSVersionCheck;
}
// List of file names to skip during installation
public List SkipFileNames { get; set; }
// List of path replacement strings
public Dictionary PathStringReplacements { get; set; }
// If true, the installer will not check to ensure the target meets the installer’s version requirements
public bool SkipOSVersionCheck { get; set; }

public override void OnInstallBegin()
{
m_fileCount = 0;
}

public override void OnTargetOSVersionCheck()
{
// check to see if we should skip the OS version check
if (!SkipOSVersionCheck)
{
base.OnTargetOSVersionCheck();
}
}

public override void OnInstallFile(ref FileInstallInfo fileInfo, out bool skipped)
{
// check to see if it’s a name we should skip
if (SkipFileNames.Find(fileInfo.FileName) != null)
{
Utility.Output(string.Format(“Skipping file ‘{0}'”, fileInfo.FileName));
skipped = true;
return;
}

// do any path replacements
foreach (KeyValuePair val in PathStringReplacements)
{
fileInfo.DestinationFolder = fileInfo.DestinationFolder.Replace(val.Key, val.Value);
}
Utility.Output(string.Format(“Installing ‘{0}’ to ‘{1}'”, fileInfo.FileName, fileInfo.DestinationFolder));
base.OnInstallFile(ref fileInfo, out skipped);
if (FileProgress != null)
{
FileProgress((++m_fileCount * 100) / FileCount);
}
}
}
}

    Update

The CAB Installer SDK is now available free as a shared-source project on Codeplex.

4 thoughts on “Announcing the CAB Installer SDK”

  1. Hi Chris –

    Purchased and downloaded the SDK yesterday for evaluation, and so far I’m really liking it! My application runs on about 5 different PDA models. The models range from legacy Dell Axims running PPC2003 all the way up to WM6 devices, so until now I’ve had to build a new installer for each model/OS. As you can imagine, I think this SDK will save me some time, but I’m still tinkering with the features.

    One point of clarification for other developers: I’ve had to tweak some of the project files to get them to compile, as I use VS 2005 and I’m still using .NETCF 2.0, so things like C# 3.0’s "bodyless gets n’ sets" have to be fleshed out. For example:

    public string Foo
    {
    get; set;
    }

    …will need to be:

    private string m_foo;

    public string Foo {
    get {return m_foo;}
    set {m_foo = value;}
    }

    This is probably obvious to experienced C# devs, but I’m a VB guy so it took me awhile to figure it out.

    Like

  2. Chris – I learned a great deal from your blog posting on PPC deployment here:
    http://blog.opennetcf.com/ctacke/CommentView,guid,1d127155-878e-4f52-8f47-73a44e698174.aspx

    I thank you sincerely for that effort. Unfortunately I’m getting MSI errors that seem like they’re Caspol issues. So now I have to make a choice between figuring that out – and the next issue, and the next… or taking a look at your CAB Installer SDK.

    What I’m concerned about is the time that will be required to learn a whole new environment, just so I can deploy my code. In today’s world we need to get through N tiers of education to create n-tier environments. At some point we have to stop being slaves to the tools, and yet here we are faced with learning the nuances of PPC deployment, because Microsoft hasn’t improved it or documented it in years, or learning yet another class library that has nothing to do with our own application code.

    I respect and appreciate the new progressive pricing model for this, and as a developer and business man I "get it" and am quite happy to send to you some percentage of any sale I make of whatever I sell based on your tools. That percentage increases as some perceived amount of pain is relieved. And conversely, the more time/effort that needs to be put into learning a new library, more we’re just seeing pain of a different kind here, and the less we all make.

    So from your perspective, how fast can we get productive with this installer? And since I’m just on the cusp transferring development from VS2005 to VS2008, is the library heavily based on .NET 3.x, to a point where I simply cannot use .NET 2 any more? Understand that this increases the "pain in a different direction issue". If I need to change my development platform in order to have easier deployment, I need to understand ahead of time that the effort will be worth the pain. And I’m really concerned about supporting older devices – maybe what I’m not understanding here is whether your .NET 3 installer SDK can deploy my .NET 2 applications.

    Sorry for rattling – I’m sure you understand the concerns or you wouldn’t have spent so much time on this.

    Thanks.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s