- Select the "Setup Project" in vs2005 and press F4.
- Change the "PostBuildEvent" to
wscript "$(ProjectDir)UpdateMSI.vbs" "$(BuiltOuputPath)" "$(ProjectDir)" $(Configuration). - Place the UpdateMSI.vbs file in "$(ProjectDir)". This file can be found here.
Monday, 9 March 2009
Programmatically change the 'ProductName', 'ProductCode', 'UpgradeCode' and 'ShortCut' depending on build Configuration.
Use the following to update the 'ProductName', 'ProductCode', 'UpgradeCode' and 'ShortCut' in a MSI setup after it has been build in vs2005:
Subscribe to:
Post Comments (Atom)
can you paste the code from vbs into this page?
ReplyDeletethanks.
BuiltOuputPath = Wscript.Arguments(0)
ReplyDeleteProjectDir = Wscript.Arguments(1)
Configuration = Wscript.Arguments(2)
ProductName = "MyApplication - " & Configuration
ShortcutName = "MYAPP~2|" & ProductName 'Check this with orca.exe
select case Configuration
case "Debug"
UpgradeCode = "{11A3CB76-5DAC-4B9F-A993-401BE1D95A9E}"
ProductCode = "{E1BFC46C-6226-459C-BC4F-8DE17888ED62}"
case "Test"
UpgradeCode = "{B15A5EAA-FA9C-4BB7-AD68-29DAE5C95846}"
ProductCode = "{F183C852-5DBC-498C-89F1-2D6CDFF515B6}"
case "Production"
UpgradeCode = "{E14EC8A9-FA0B-47B8-84EB-4EC7ED278E7E}"
ProductCode = "{016C6EF8-A23F-4822-96B2-E0A1D74641EE}"
case Else
end select
'guid = CreateObject("Scriptlet.TypeLib").Guid
'UpgradeCode = left(guid, len(guid) - 2)
Const msiOpenDatabaseModeTransact = 1
Dim propertyKey, propertyValue
Dim installer, database, view, record
Set installer = CreateObject("WindowsInstaller.Installer")
Set db = Installer.OpenDatabase(BuiltOuputPath, msiOpenDatabaseModeTransact)
Set view = db.OpenView("UPDATE Property SET Value = '" & ProductName & "' WHERE Property = '" & "ProductName" & "'")
view.Execute
Set view = db.OpenView("UPDATE Property SET Value = '" & ProductCode & "' WHERE Property = '" & "ProductCode" & "'")
view.Execute
Set view = db.OpenView("UPDATE Property SET Value = '" & UpgradeCode & "' WHERE Property = '" & "UpgradeCode" & "'")
view.Execute
Set view = db.OpenView("UPDATE Shortcut SET Name = '" & ShortcutName & "' WHERE Description = 'MyApplication Application'")
view.Execute
'Set view = db.OpenView("UPDATE Upgrade SET UpgradeCode = '" & UpgradeCode & "'")
'view.Execute
db.Commit
Set installer = Nothing
Set db = Nothing
Set view = Nothing
any sample in Powershell ps1 script ?
DeleteHow the MSI will be called/triggered.?
ReplyDeletephysically where we have to place the vbs file ?
Does user need to trigger msi / vbs to get install?
Please help on this.
Can we pass those 3 arguments when we trigger MSI?
ReplyDeleteCall the VBS in the post-build event from the Web.Setup project:
ReplyDelete"PostBuildEvent" = "8:wscript \"$(ProjectDir)UpdateMSI.vbs\" \"$(BuiltOuputPath)\" \"$(ProjectDir)\" $(Configuration)"