Monday, March 3, 2008

Automated Install Testing - MSI Validation

An introduction to this article can be found in this previous post. -- Automated Install Testing

MSI Validation is the first series of tests that come to mind. MSI Validation runs tests on the MSI package, these test are called Internal Consistency Evaluators (ICE). They can find bad conditions, duplicate file targets, invalid records, per/user issues and so on...

MSI Validation is nice because, the ICEs are written by Microsoft you just need to run them. You can also write your own custom ones however, for now we will just use Microsoft’s.

To run validation manually, just edit you MSI package with Orca, choose Tools->Validate.

Validating the MSI package manually is fine however, we want to automate it. Then the validation can be fit into the nightly build process. As the MSI package evolves over the course of the development cycle, the ICEs will continually run.

The Platform SDK contains a command line tool that will run the tests for us. MsiVal2.exe -- to install it find MsiVal2.msi, which is located in the Platform SDK directory.

MsiVal2.msi contains MsiVa2.exe and some .cub files. The CUB files contain the actual ICEs to execute. Darice.cub contains all of the MSI ICE's and equates to Full MSI Validation Suite, the other ones contain a subset of them. So, for our example we will stick with Darice.cub



Running MSI Validation from the command line:
MsiVal2.exe <Msi Package> <.cub file> /l"Output file" /f

Example:
MsiVal2.exe "C:\My Path\My.msi" "darice.cub” /l “C:\My Path\Validation.log” /f

The output:
MSI Validation typically contains 3 levels of output (Info, Warnings, and Errors). For the most part, you will want to fix most (if not all errors). However, we don’t need or really concern ourselves so much with the info messages and warnings. Now that we know the command line to run MSI Validation, all we have to do is fit it into our build process.  Regardless, of the build tools (VBScript, Pearl, Visual Build, Batch Files ...), MSI Validation can be run on the installation package.

The default MS ICEs can help you resolve numerous problems with the installation package. However, they won’t find them all. Next we will look at how to write your own custom ICEs so that you can extend the MSI Package validation.  Coming soon ...

MSI Package Validation:
http://msdn2.microsoft.com/en-us/library/aa370569(VS.85).aspx

Internal Consistency Evaluators Reference:
http://msdn2.microsoft.com/en-us/library/aa369206.aspx

MsiVal2.exe
http://msdn2.microsoft.com/en-us/library/aa370504(VS.85).aspx

Validation Automation:
MsiVal2.exe works great, but it is limited. If more functionality is required automated validation can also be performed via COM (using the Evalcom2 interface). More information can be found here;
http://msdn2.microsoft.com/en-us/library/aa372415(VS.85).aspx

1 comment:

Karin said...

You can find the MsiVal2.exe in the Windows SDK for Server 2008 and .NET Framework 3.5, which was released Feb 2008. The Windows SDK has replaced the old “Platform SDKs.” Read about the latest release and find download links here:

http://blogs.msdn.com/windowssdk/archive/2008/02/07/windows-sdk-rtms.aspx

The tool installs as an MSI to this location by default: C:\Program Files\Microsoft SDKs\Windows\v6.1\bin\MsiVal2.msi.

If you’re using one of the Visual Studio 2008 SKUs you’ll find this tool in the SDK components that ship embedded in Visual Studio. It will install to an SDK directory: C:\Program Files\Microsoft SDKs\Windows\v6.1\bin\MsiVal2.msi.