Author Archive

For some time now, I’ve struggled to work out how to build the WiX files that are generated by MSI Factory in FinalBuilder and include the bootstrapper. Building WiX files in FinalBuilder is dead easy – it has actions for the WiX Candle and the WiX linker so you can compile the files that MSI Factory generates (or any other WiX files of course) quite easily. But once you have your MSI, it is nice to have the EXE wrapper for bootstrapping it. Why does this matter? Because if you issue an update to your MSI file, and then double-click to run it, Windows will tell the user they must manually uninstall the app before they can install the update. Not so friendly.

Okay, so what’s so hard? The bootstrap compiler takes a number of options, and they include the GUIDs that are needed to check if it is installed already. The problem is that you don’t know the GUID in the build. It turns out that the answer is simple, but it took some time to find, so I’m blogging it so I remember for next time.

The MSI Factory software comes with a command line tool called “IRMakeBootstrap.exe”. This takes an XML configuration file and the name of the output file as parameters, and the product name, but also then needs three parameters that are key to proper operation.

The key ones are -var:PackageCode and -var:ProductCode. Now if you look at your WiX file you will see that it has a line like:

<Product Id="D03192D5-40A2-4EAC-B1A1-9BACE96AFE78" Name="My App Name" Version="1.0.0" Manufacturer="My Company" UpgradeCode="76D9BEB2-C077-4B7C-A91E-DF294F4C3457" Language="1033">

The “Id” matches the “Product Code” , and the “UpgradeCode” matches the Upgrade code, in the Project settings dialog of MSI Factory. However, the PackageCode is not in the file at all. There is a Package node in the XML, but no value. If you look in MSI Factories dialog, there is a “Package ID” on the Package tab, but it says “leave blank to auto-generate”. But if that is left blank, I can’t find out what it is to set it to something useful, and thus pass to the bootstrap maker.

Okay, so what is the solution? Simple. Define a GUID in the dialog for the Package ID in the MSI Factory dialog. This is normally a “bad thing”, because you want to to change each time (pretty much essential). But you are doing better anyway by using FinalBuilder (or other build tool?) and FinalBuilder is able to generate a GUID just fine. So, set it to a valid GUID string, and then generate the WiX files.

<Package Id="59D9FCDF-13BE-4AD7-841B-1F11D2E74500" ...

You will now find that the XML contains an “Id” for the package too. Haha! Now you have what you need to automate it. The value in the XML can now be replaced in your script, and also passed through to the bootstrap builder. Note that the GUIDs passed to the bootstrap builder need the curly brackets surrounding them. This ensures that they match properly.

Finally, you can check that it all works properly by running your install EXE with the “/Log:c:\install.txt” parameter which causes it to output a log of its activities.

The final parameters for  the bootstrap maker is:

 

"D:\Src\bootstrap_config.xml" "D:\Src\MySetup.exe" -var:AllowExtractMSI=1 -var:ProductName="Product Name"  -var:PackageCode="{%INST_PACKAGECODE%}"  -var:ProductCode="{%INST_PRODUCTCODE%}" -var:ProductVersion=%VERSION_MAJOR%.%VERSION_MINOR%.%VERSION_BUILD%

I think Apple should be banned from making the iPad. And tablet PCs
generally should be banned.

Think about how kids will grow up having tablets in the house as common items. They will watch TV programmes like Star Trek and see them using the PADD that was ahead of its time, and the kids will think it is just normal! No people, such things are the future! The Star Trek communicator already looks old fashioned, and what is going to be left for kids to think are not normal but futuristic?

Ban them now!

Edit: I’ve been to see Avatar, and the world is set to right again. Clear “glass” pads and lovely 3D visualisers. It will be a year or two before Apple or anyone brings out devices like that. The future is safe.

EnTabFile is a tool to convert the spaces at the start of each line in a file to tabs. This allows them to work better in editors that support proper tabs. It is primarily designed to be used as a command line tool, but supports manual operation too.

How EnTab works

This tool is quite simple – it just removes spaces at the start of each line of an ANSI text file and replaces them with tab characters. It does not replace any spaces anywhere else in the line – it stops once it find anything that isn’t a space.

The number of spaces used for each tab is settable in the user interfaace, but the tool is really designed to be used from the command line as part of a bigger process – perhaps source code reformatting using something like DelForExp. Set DelForExp to output 4 spaces for each tab, and then use EnTabFile to convert every 4 spaces into a tab.

Note that if an incomplete set of spaces is found, a tab will still be output. Thus if there are 6 spaces and the tab setting is 4, then 2 tabs will be output. No spaces are ever left at the start of a line.

For safety, it will save an original copy with the extension “.pretab” that you can use to compare. If it already exists, no copy is made so that the entab can be done multiple times and the original is still there.

Manual use:

Run the application, and type in the name of the file you wish to entab. You can click the ‘…’ button to use a browser.

Select the number of spaces per tab.

Click “Entab” and it will be loaded, converted, and saved. A progress bar shows the activity.

Command line use:

Run the application with the filepath for the file you want converted. The full path should be specified for proper operation of the backup.

Only a single file can be specified on the command line.

You can specify the tab size using the command line switch /1, /2 /3 /4 /5 /6 /7 or /8.

With a command line, the app will convert the file (if it exists!) and then close immediately.

Delphi Integration:

For use within Delphi, you can add it to the Tools menu. The following are suggestions:

Title: EnTab this file
Program: [PATH TO FILE]\EnTabFile.exe
Working Directory: [PATH TO FILE]
Parameters: $SAVE $EDNAME

Note that if run after DelForExp, you will have to save before it can convert. After Entabbing, Delphi will say the file has changed and do you want to reload. The answer should always be yes or the tabs will not be loaded!

Download

A zip file with these basic instructions and the self-contained application are available via the link: EnTab for Windows. No installer is needed – just put the file in a suitable location, unzip it, and start using it.

Our back-yard

Tony Richards' picture of Lake District mountains

View more pictures of the English Lake District at Tony Richards' lakelandcam.co.uk

Tweets