Friday 8 March 2013

Why we use Cassini instead of IIS Express

Following the IIS vs Cassini different behaviors on ASP.NET Server.Transfer  post, Barry commented on Twitter that I should use IIS Express instead:

image

so I decided to try it (which you can read bellow)

TL DR:
  • I couldn't install IIS Express on my dev box (a bad start for something that needs to be easy to deploy and run)
  • Cassini is ONE file (and it works as long as .NET 4 is installed)
  • I can run multiple instances of Cassini (regardless of what other web servers are installed)
  • Even if IIS Express can be installed (or extracted) there are a tons of files in there
  • IIS Express can only be distributed in an MSI format (which requires an install)
  • Cassini’s source code is available
Since my objective with TeamMentor is to make the install/eval process as smooth as possible, it is clear that Cassini is the right option. At the moment to run a local copy of TeamMentor (for example the eval version with the OWASP library) you just download a zip file , unzip it, and click on Start TeamMentor.bat (which is almost as simple as it gets)

What follows is my attempt to use IIS Express:

Trying to use IIS Express

Ok, so I found the download page for the IIS Express MSI (there doesn't seem to be a zip file which 'just runs' without requiring an installation process)

image

Clicking on the Download Button, redirects to this page:

image  which triggers a download from this address

image

With that link at hand, I quickly opened up the the O2 Platform and wrote this installer script:

image

This script when executed, downloads the MSI, and executes the MSI.

...which failed:

image

This revealed a first prob with a couple core requirements of TeamMentor's installation:
  • support for side-by-side installs of IIS express and 
  • stand-alone 'run from zip' distribution packages
Now, these O2 driven downloads are placed in the _O2Downloads temp dir

image

so let’s see if we can control where the target MSI installation.

Running the MSI installer with /? arguments shows the Install Options:

image

Here is the text from these options, and unless I’m blind, there is no way to define the target folder:
Windows ® Installer. V 5.0.7601.17514 

msiexec /Option <Required Parameter> [Optional Parameter]

Install Options
    </package | /i> <Product.msi>
        Installs or configures a product
    /a <Product.msi>
        Administrative install - Installs a product on the network
    /j<u|m> <Product.msi> [/t <Transform List>] [/g <Language ID>]
        Advertises a product - m to all users, u to current user
    </uninstall | /x> <Product.msi | ProductCode>
        Uninstalls the product
Display Options
    /quiet
        Quiet mode, no user interaction
    /passive
        Unattended mode - progress bar only
    /q[n|b|r|f]
        Sets user interface level
        n - No UI
        b - Basic UI
        r - Reduced UI
        f - Full UI (default)
    /help
        Help information
Restart Options
    /norestart
        Do not restart after the installation is complete
    /promptrestart
        Prompts the user for restart if necessary
    /forcerestart
        Always restart the computer after installation
Logging Options
    /l[i|w|e|a|r|u|c|m|o|p|v|x|+|!|*] <LogFile>
        i - Status messages
        w - Nonfatal warnings
        e - All error messages
        a - Start up of actions
        r - Action-specific records
        u - User requests
        c - Initial UI parameters
        m - Out-of-memory or fatal exit information
        o - Out-of-disk-space messages
        p - Terminal properties
        v - Verbose output
        x - Extra debugging information
        + - Append to existing log file
        ! - Flush each line to the log
        * - Log all information, except for v and x options
    /log <LogFile>
        Equivalent of /l* <LogFile>
Update Options
    /update <Update1.msp>[;Update2.msp]
        Applies update(s)
    /uninstall <PatchCodeGuid>[;Update2.msp] /package <Product.msi | ProductCode>
        Remove update(s) for a product
Repair Options
    /f[p|e|c|m|s|o|d|a|u|v] <Product.msi | ProductCode>
        Repairs a product
        p - only if file is missing
        o - if file is missing or an older version is installed (default)
        e - if file is missing or an equal or older version is installed
        d - if file is missing or a different version is installed
        c - if file is missing or checksum does not match the calculated value
        a - forces all files to be reinstalled
        u - all required user-specific registry entries (default)
        m - all required computer-specific registry entries (default)
        s - all existing shortcuts (default)
        v - runs from source and recaches local package
Setting Public Properties
    [PROPERTY=PropertyValue]

Consult the Windows ® Installer SDK for additional documentation on the
command line syntax.

Copyright © Microsoft Corporation. All rights reserved.
Portions of this software are based in part on the work of the Independent JPEG Group.


So, lets try option B, extract the MSI ourselves.

Instead of using the installFromMsi_Web() method

image

lets use the install_JustMsiExtract_into_TargetDir() one instead:

image

This will extract (without install) the MSI into the O2’s _ToolsOrApis folder (MSI extraction done using the LessMSI tool)

image

The 'MSI Extracted' (i.e. unzipped) folder looks like this:

image

The cabs folder is empty, and the SourceDir has the IIS Express Folder

image

Which contains 100 items:

image image

image image

That is a LOT of stuff, I was looking for 1 file (just like Cassini does it)

Inside it, there is the iisexpress.exe

image

which when executed throws this error:

image

this seems to imply that IIS Express needs to be ‘installed’ into the local box in order for it to run (again something that I don’t want)

At this stage I gave up on trying to use IIS Express :)

Just to put into perspective:

Cassini can be downloaded from here: http://cassinidev.codeplex.com/releases/view/45828

image

It comes in a zip file, which when extracted looks like this:

image

Cassini can be started by just executing one file (note that the multiple exes shown above cover a number of framework and deployment options):

Here is an O2 script to download and start Cassini locally:

image

Just to re-enforce the concept that all that is needed is one file, in TeamMentor, we ship the 168k CassiniDev_4.0.exe:

image

which is then triggered via a simple batch file:

image

Now, THAT's more like it. Barry, let me know when IIS Express is shipped like that, and I take another look.

On the topic of redistribution

Btw ,It also looks like that the IIS Express files can't be redistributed individually, and only the MSI (which failed to install on my box) is allowed to be officially redistributed:

image

One of these days Microsoft will learn the beauty of Simple, Elegant and non-complex solutions.