Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Automating Builds


2 replies to this topic

Superfreak3

Superfreak3
  • Full Members
  • 437 posts

Posted 25 February 2002 - 15:02

When automating a build from, let's say, the command line, is it possible to bump the version number by one and change the package/product codes  automatically?  Also, is it possible to bump the Max vesion in the upgrade table to match the current verison?

Thanks for any info.!


Irina

Irina
  • Members
  • 227 posts

Posted 25 February 2002 - 18:09

Hi,
You can use this VB code to bump the version number and change the package code. Execute this code from the command line with your .ism file as a parameter.

Option Explicit

Public Type GUID_t
   Data1 As Long
   Data2 As Integer
   Data3 As Integer
   Data4(7) As Byte
End Type

Public Const S_OK = 0

Private Declare Function CoCreateGuid Lib "OLE32.dll" (pGuid As GUID_t) As Long

Private Declare Function StringFromGUID2 Lib "OLE32.dll" _
   (ByRef rguid As GUID_t, ByVal lpsz As String, ByVal cchMax As Long) As Integer
   
Sub Main()

Dim oProject 'as ISWiAutomation.ISWiProject
Dim newGuid As GUID_t
Dim strIsmPath As String, strPackageCode As String
Dim iChars As Integer, lReturn As Long
Dim szTemp As String, szProductVersion As String
Dim iVersion As Integer
Dim szAdd
Dim szSplitVersion() As String

On Error GoTo ErrorHandler

If Command$ = "" Then
   MsgBox "Usage: ChangePackageCode [path to ism project]", vbInformation + vbOKOnly
   Exit Sub
End If

strIsmPath = Command$

' in case user put ISM path in quotation marks...
If Left$(strIsmPath, 1) = """" Then
   strIsmPath = Right$(strIsmPath, Len(strIsmPath) - 1)
   strIsmPath = Left$(strIsmPath, Len(strIsmPath) - 1)
End If

' generate new package code
lReturn = CoCreateGuid(newGuid)

If (lReturn <> S_OK) Then
   MsgBox "CoCreateGuid failed!", vbExclamation
   Exit Sub
End If

' convert package code to string
strPackageCode = Space(100)
iChars = StringFromGUID2(newGuid, strPackageCode, Len(strPackageCode))
strPackageCode = StrConv(strPackageCode, vbFromUnicode)
strPackageCode = Left(strPackageCode, iChars - 1)
strPackageCode = UCase(strPackageCode)

Set oProject = CreateObject("ISWiAutomation.ISWiProject")

oProject.OpenProject strIsmPath

' set new package code for .ism project
oProject.PackageCode = strPackageCode

' increase Product Version on 1 (x.x.[xxxx] mat be less digits then 4)
' get digits after last "."
szProductVersion = oProject.ProductVersion
szSplitVersion = Split(szProductVersion, ".")
szTemp = szSplitVersion(2)

' convert to number and increase
iVersion = CInt(szTemp) + 1

' convert to string
szTemp = CStr(iVersion)

szProductVersion = szSplitVersion(0) + "." + szSplitVersion(1) + "." + szTemp
oProject.ProductVersion = szProductVersion

oProject.SaveProject
oProject.CloseProject

Set oProject = Nothing

Exit Sub

ErrorHandler:
MsgBox "Something happend!" & vbCrLf & vbCrLf & _
   "Error number: " & Err.Number & _
   "Error description: " & vbCrLf & Err.Description
   
End Sub

You have an access to another properties of your project from the ISWiAutomation.ISWiProject.


Superfreak3

Superfreak3
  • Full Members
  • 437 posts

Posted 25 February 2002 - 21:54

Thanks.  I'll give this a whirl!