Menu

Creating an Internal Consistency Evaluator

September 23, 2009 - Windows Installer

Example of Creating an Internal Consistency Evaluator (ICE) using Orca

Whilst the ICE list is pretty comprehensive there will be a point where you need to validate information that is not covered by the standard ICE unit tests, to do this you will need to add your own Internal Consistency Evaluator.

Here is an example of creating a vbscript Internal Consistency Evaluator wdICE01 to check that no hard coded paths (c :) have been entered into the Registry table, wdICE01.vbs will be used to populate necessary tables in darice.cub

1.       Append the .ibd file extension to your vbscript                  example: wdICE01.vbs.ibd

2.       Using Orca, Open C:Program Filesorcadarice.cub

3.       Select Binary table and add new row (CTRL & R).

Binary Table add new row

Binary Table add new row

Enter Name of VBScript in name field.

Enter the path to the location of ibd file into the Data field (or Browse…) and click OK to add new row.

4.       Select CustomAction table and add new row

Custom Action table add new row

Custom Action table add new row

Enter ICE name into Action field

Enter Type into Type field (see table below)

Enter VBScript into Source field

Enter ICE name into Target field and click OK to add new row.

5.       Select _ICESequence table and add new row

_ICESequence table add new row

_ICESequence table add new row

Enter ICE into Action field
Leave Condition empty

Enter sequence number into Sequence field and click OK to add new row.

Its a good idea to use a sequence number is greater than 1000 as not to interfere with built-in ICE sequences.

Save darice.cub (CTRL & L)

6.       Open MSI package and Validation Output (CTRL & L)

Validation Output Windows

Validation Output Window

Click Go (ALT & G)

When validation has completed results are displayed, Click Close

The Table Error symbol |appears to the left hand-side of Tables containing ICE messages

Orca ICE Validation Window

Orca ICE Validation Window

The validation pane lists Warning and Errors found when the validation has been run and can be used to quickly change the table list window and table view focus highlighting the location of a specific validation error.

Example

Here is an example vbscript if you want to try it out

Function wdICE02()
On Error Resume Next

	Set recInfo=Installer.CreateRecord(1)
	If Err <> 0 Then
		wdICE02 = 1
		Exit Function
	End If

	'Give description of test
	recInfo.StringData(0)="wdICE02" & vbTab & "3" & vbTab & "wdICE02 - Performs a non case sensitive search for C: hard coded into the IniFile table  "
	Message &h03000000, recInfo

	'Give creation data
	recInfo.StringData(0)="wdICE02" & vbTab & "3" & vbTab & "Created 23/03/07. Last Modified 23/03/07."
	Message &h03000000, recInfo

	'Is there a IniFile table in the database?
	iStat = Database.TablePersistent("IniFile")
	If 1 <> iStat Then
		recInfo.StringData(0)="wdICE02" & vbTab & "3" & vbTab & "'IniFile' table missing, wdICE02 cannot continue its validation."
		Message &h03000000, recInfo
		wdICE02 = 1
		Exit Function
	End If

	'process table
	'					[1]	   [2]	    [3]	    [4]
	Set View = Database.OpenView("SELECT `IniFile`,`FileName`,`Key`,`Value` FROM `IniFile`")
	view.Execute

	If Err <> 0 Then
		recInfo.StringData(0)="wdICE02" & vbTab & "0" & vbTab & "view.Execute_1 API Error"
		Message &h03000000, recInfo
		wdICE02=1
		Exit Function
	End If 

	Do
		Set rec=view.Fetch
		If rec Is Nothing Then Exit Do

		'check for hardcoded string.
		If InStr(1,rec.StringData(4),"c:",1) > 0 Then
			'Name of ICE  Message Type  Description  Help URL or location  Table Name  Column Name  Primary Key  Primary Key  Primary Key
			'(repeat for as many primary keys as needed)                  	http://msdn2.microsoft.com/en-us/library/aa369205.aspx
			rec.StringData(0)="wdICE02" & vbTab & "2" & vbTab &  "Path [4] is hard coded in [3] key within [2]" & vbTab & "" & vbTab & "IniFile" & vbTab & "IniFile" & vbTab & "[1]"
			Message &h03000000,rec
		End If
	Loop

	'Return iesSuccess
	wdICE02 = 1
	Exit Function
End Function

Leave a Reply