Thursday, June 25, 2009

MSP - Patching rules

If you create a new version of your program and want to be able to update existing installations either with a full install package or with a patch package, you must follow some rules. Breaking these rules will cause strange effects like previously installed features appearing as advertised after the update, or files not getting updated features not getting installed etc. If you are not following them, you can expect your MSP to lead you no where :)

Some rules small and minor updates : 

  1. Follow the rules for changing or keeping the ProductCode, ProductVersion and UpgradeCode, depending of the type of update you are creating. 
  2. Always change the package code.
  3. Do not move componentes to other features.
  4. Do not move sub features. You can add new features and sub features.
  5. You can add components to existing features. If you want to add a new feature you can synchronize the installation state of a new child feature with its parent feature by setting its Remote Installation property to "Favor Parent" and its Required property to yes.
  6. Do not change component codes.
  7. Do not change the name of the key file of a component.
  8. You can modify the contents of a component (add, remove or modify files, registry keys and shortcuts), but only if that component is not shared across features.
  9. If you remove a file or registry key from a component, you must populate the RemoveFile or RemoveRegistry table respectively to delete the orphaned resource.
  10. Do not change the name of the .msi file.

Ref: Stefan Krueger@http://www.installsite.org/pages/en/msi/updates.htm


Wednesday, June 17, 2009

MultiLanguage Patch - MSP


If you are thinking about some command for MSI installer to do so, there is'nt any. What we are going to implement is a Hack where we can deploy the langauage transforms before applying the patch.

How we are going to do this is
1) Get MST files from the Installshield build output folder
2) Create a Package using NullSoft Installer( its easy)
3) Write code in nullsoft to replace the MST file locally
4) Extract the update.exe or MSP and run

Original MST file is stored in C:\WINDOWS\Installer\{PROD_CODE}\1031.MST, you can find out the path by reading HKLM\SOFTWARE\Classes\Installer\Products\MY.PROD.GUID and value of transforms key. Now you can go and replace this file and run the patch. Below is the code for doing this. Use NSIS compiler to compile it.

; Script generated by the HM NIS Edit Script Wizard.

; HM NIS Edit Wizard helper defines
!define PRODUCT_VERSION "3.3"
!define PRODUCT_PUBLISHER "ItsMe"
!define PRODUCT_WEB_SITE "http://www.MySite.com"

; MUI 1.67 compatible ------
!include "MUI.nsh"


!define MUI_ICON "Developer.ico"

;
; Language files
!insertmacro MUI_LANGUAGE "English"



SetCompress auto
OutFile "Patch.exe"
Function .onInit

SetSilent silent

FunctionEnd


Section "MainSection" SEC01
SetOutPath "$tempdir"
SetOverwrite ifnewer
File "D:\Build Output\Patch\Update.exe"
File "D:\BuildOutput\Product Configuration 1\Release 1\DiskImages\DISK1\1031.mst"
File "D:\BuildOutput\Product Configuration 1\Release 1\DiskImages\DISK1\1032.mst"
File "D:\BuildOutput\Product Configuration 1\Release 1\DiskImages\DISK1\1033.mst"
File "D:\BuildOutput\Product Configuration 1\Release 1\DiskImages\DISK1\1034.mst"
File "D:\BuildOutput\Product Configuration 1\Release 1\DiskImages\DISK1\1036.mst"
File "D:\BuildOutput\Product Configuration 1\Release 1\DiskImages\DISK1\1041.mst"
File "D:\BuildOutput\Product Configuration 1\Release 1\DiskImages\DISK1\1040.mst"
File "D:\BuildOutput\Product Configuration 1\Release 1\DiskImages\DISK1\1043.mst"
File "D:\BuildOutput\Product Configuration 1\Release 1\DiskImages\DISK1\1046.mst"

ReadRegStr $0 HKLM "SOFTWARE\Classes\Installer\Products\MY.PROD.GUID" "transforms"

; remove
StrCpy $1 $0 "" -8

Rename $0 "$0.bak"
CopyFiles $tempdir\$1 $0

exec "$tempdir\Update.exe"
SectionEnd

Section -AdditionalIcons
SectionEnd

Section -Post
SectionEnd