Skip to main content

Wise Installer 0, James 1

As you may have read in previous posts I've been using Wise Installer to create MSI files of our software for the PocketPC and Smartphone. However a deadline on Wednesday to go and demonstrate one of our applications and a still non-functional Wise installer led me to return to basics and get down and dirty with .CAB, .INF, .INI & .MSI's...and guess what? It's actually not too unbearable!

Starting on Tuesday afternoon I had a working MSI installer with custom actions and multi-cab install in about 4 hours. The problem with getting this stuff to work is that there really isn't a great overall guide to it all. I Googled a couple of links and used the MSDN Compact Framework FAQ and after reading through it all understood pretty much what there is to know and plugged it all together. These are the links I used...




The missing ingredient in all this how to install the cab files your application is dependent upon. To locate exactly what CAB files your application will need open the "Dependencies.PPC.txt" file that is created in the Cab folder under your project once you have run "BuildCab". Have a scan through, you'll see the other .CAB files pretty easily. So how do you get these into the .MSI?


  • Follow the instructions in the first link for adding a CustomInstaller and Setup Project to your SmartDevice solution.
  • Create a .INI file for each .CAB mentioned in the Dependencies file (if you want to install it)
  • Add the .CAB files to the Setup Project. The full path to each is in the Dependencies file.
  • The secret ingredient...you can call the CEAppMgr (ActiveSync Add/Remove Programs) program with multiple .INI files on the command line parameter and it will install these one at a time.
The code below is a modification of that shown in the links above - it allows you to call the RunAppManager method with an optional number of .INI files as parameters. I have actually got another version of this that reads the .INI files from an xml manifest file but I don't want to make things too easy for you!

private void CustomInstaller_AfterInstall(object sender, InstallEventArgs e)
{
string desktopFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
// run WinCE App Manager to install .cab file on device
this.RunAppManager(desktopFolder, "OpenNETCF.ini", "YourApplication.ini");
}
private void RunAppManager(string desktopFolder, params string[] iniFiles)
{
// get path to the app manager
const string RegPath = @"Software\Microsoft\Windows\" +
@"CurrentVersion\App Paths\CEAppMgr.exe";
RegistryKey key = Registry.LocalMachine.OpenSubKey(RegPath);
string appManager = key.GetValue("") as string;

// build up the list of ini file arguments - each one needs wrapping in ""
string args = string.Empty;

for (int i = 0; i < iniFiles.Length; i++)
{
args += string.Format("\"{0}\" ", Path.Combine(desktopFolder, iniFiles[i]));
}


if (appManager != null)
{
// launch the app
//MessageBox.Show(appManager + "\n" + args);
Process.Start(string.Format("\"{0}\"", appManager), args);
}
else
{
// could not locate app manager
MessageBox.Show("Could not launch the WinCE Application Manager.");
}
}


This is the INI file for OpenNETCF. The text in red must match up and DO NOT have any spaces between the files and commas in the CabFiles list. The list below has a line break just for formatting sake but it should be all one continuous line.

[CEAppManager]
Version = 1.0
Component = OpenNETSDF

[OpenNETSDF]
Description = OpenNETCF SDF.
CabFiles = OpenNETCF.SDF.PPC3.ARM.CAB,

OpenNETCF.SDF.PPC3.ARMV4.CAB

This works really consistently (unlike Wise!) and I'm pleased with what I've acheived. I have plans for creating a Visual Studio.NET addin to run the CAB build and scan the Dependency file and automatically create the Setup Project with the right CAB and INI files in it for you but that's another story.

You can customise the installer using WinForms/.NET in the AfterInstall and Uninstall events so you can make the whole thing pretty slick. Have a go, it's not as tricky as it looks!

And to make it even easier these links tumbled out of the blog-sphere the day after I had done all this! DOH!





Comments

Anonymous said…
After struggling for 2/3 days with this problem. I was releived to find that this article gave me the solution in less than 20 mins of effort!
Thanks James
Anonymous said…
I also struggled for 10-20 hours and almost deciding to give up before finding your blog. Thanks SOOOO much.
Anonymous said…
Thanks! You rock... even 2 years after the fact.

Popular posts from this blog

Configuration in .Net 2.0

11-Dec-2007 Update I've updated this post to fix the broken images and replaced them with inline text for the example xml and accompanying C# code. This post has been by far the most hit on this blog and along with the comments about the missing images I thought it was time to update it! Whilst recreating the examples below I zipped up the working source code and xml file and loaded this onto my Project Distributor site - please download it to get a full working custom configuration to play with! Just click on the CustomConfigExampleSource link on the right hand side, then the "Source" link to get the zip. We are in the process of converting our codebase to .Net 2.0. We've used Enterprise Library to great effect so decided that we should continue with this in the form of the Jan 2006 release which targets 2.0 and I've got the job of porting our Logging, Data Access etc wrappers to EntLib 2.0. ...And so far so good - the EntLib docs aren't bad and the migrati...

Walk-Thru: Using Wolfpack to automatically deploy and smoke test your system

First, some history... The advent of NuGet has revolutionised many many aspects of the .Net ecosystem; MyGet, Chocolatey & OctopusDeploy to name a few solutions building upon its success bring even more features to the table. I also spotted that NuGet could solve a problem I was having with my OSS System Monitoring software Wolfpack ; essentially this is a core application framework that uses plugins for extension ( Wolfpack Contrib ) but how to unify, standardise and streamline how these plugins are made available? NuGet to the rescue again - I wrapped the NuGet infrastructure (I deem NuGet to be so ubiquitous and stable that is has transcended into the software "infrastrucuture" hall of fame) with a new OSS project called Sidewinder . Sidewinder allows me to wrap all my little extension and plugins in NuGet packages and deploy them directly from the Wolfpack application - it even allows me to issue a new version of Wolfpack and have Wolfpack update itself, sweet huh...

Announcing FluentGeoApi - a C# wrapper to GeoAPI.com

I'm pleased to make public the fruits of my late nights.... FluentGeoApi ! I previously mentioned that I am working on a private/personal project - well it's got an element of geolocation to it and after a bit of internet research I found GeoAPI.com . In order to interact with GeoAPI I decided to write a fluent style wrapper over the top of it and I've just released v1.0.0.0, a .Net 3.5 C# library to take the pain out of making REST calls and dealing with the GeoJson wire format used by GeoAPI. It's not 100% coverage of the API but I plan on getting there ASAP...however I've implemented Create/Modify/Delete a user entity, Simple and Keyword Search which is enough to release it. If you are working with geolocation data/features in your .Net application I would check out GeoAPI.com - I've been really impressed with what if offers (and if you hit the api < 20,000 times a day it won't cost you a penny!) - hopefully you'll also consider using FluentGe...