Thanks for any info.!
Automating Builds
Posted 25 February 2002 - 15:02
Posted 25 February 2002 - 18:09
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.