Kinook Software Forum

Go Back   Kinook Software Forum > Visual Build Professional > [VBP] General Discussion
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-04-2010, 05:36 PM
citect citect is online now
Registered User
 
Join Date: 11-13-2008
Posts: 30
builder.CompletionStatus and vbld_BuildDone()

Hi

I have got the project script below. The function "CreateXmlLogHandlingProject()" is working fine if "status" = vbldBuildCompFailed but it fails to run when "status" = vbldBuildCompDone or "status" = vbldBuildCompAborted.
When the script failed the last msgbox displayed is "Test 3".


Script:


Option Explicit

Function LogExt()

If Application.Options.LogFormat = "Text" Then
LogExt = "txt"
Else
LogExt = "xml"
End If

End Function


Function vbld_BuildStarting()
' delete any existing log file before the build begins
' This can be useful if a master project calls child projects
' which use the same log file as the master project, but the
' log file should be deleted only at the start of the master build.
' The global option 'Tools | Application Options | Logging | Delete
' log file at the start of each build' would cause the log file to
' be deleted at the beginning of the master and each child project,
' so instead that option can be unchecked and this step added to the
' start of the master project.

Dim logFile, message

' determine the log filename, retrieve with all macros/script expanded
logFile = Application.ExpandMacrosAndScript("%LOGFILE%")

' delete the file if it exists
If vbld_FSO.FileExists(logFile) Then
message = "Deleting log file '" + logFile + "' from vbld_BuildStarting event (go to Script Editor, Project tab to view script code)."
Builder.LogMessage vbCrLf + message + vbCrLf

vbld_FSO.DeleteFile logFile, True
End If
End Function


Function vbld_BuildDone(status)
CreateXmlLogHandlingProject(status)
End Function




Dim objApp, objBld, objStep, objMacro
Dim toEmailObjMacro, emailSubjectObjMacro, emailContentObjMacro

Function CreateXmlLogHandlingProject(status)

' create VisBuildPro app and build objects and connect
Set objBld = CreateObject("VisBuildSvr7.Builder")
Set objApp = CreateObject("VisBuildSvr7.Application")

objBld.Initialize objApp

' create a "XmlFilePath" macro containing the path of this project log file
Set objMacro = objApp.Project.Macros.Add("XmlFilePath")
objMacro.Value = Application.ExpandMacrosAndScript("%LOGFILE%")

' create a "HtmlFilePath" macro containing the path of the log file transformation result
Set objMacro = objApp.Project.Macros.Add("HtmlFilePath")
objMacro.Value = "%TEMP%\%PROJROOT%.html"
objMacro.Value = Application.ExpandMacrosAndScript(objMacro.Value)

' create a "LogFormat" macro indicating the format of this project log file
Set objMacro = objApp.Project.Macros.Add("LogFormat")
objMacro.Value = Application.Options.LogFormat

msgbox "status = " & status, vbOK, "CreateXmlLogHandlingProject"
msgbox "Test 1", vbOK, "CreateXmlLogHandlingProject"

' create a "TO_EMAIL" macro containing the email distribution list
Set objMacro = objApp.Project.Macros.Add("TO_EMAIL")
Select case status
case vbldBuildCompDone
objMacro.Value = ""%myEmail%"
case vbldBuildCompAborted
objMacro.Value = ""%myEmail%"
case vbldBuildCompFailed
objMacro.Value = "%myEmail%"
case else
objMacro.Value = ""%myEmail%"
end Select

msgbox "Test 2, objMacro.Value = " & objMacro.Value, vbOK, "CreateXmlLogHandlingProject"

' create a "EmailSubject" macro containing the subject of the email
Set objMacro = objApp.Project.Macros.Add("EmailSubject")

msgbox "Test 3", vbOK, "CreateXmlLogHandlingProject"

Select case status
case vbldBuildCompDone
objMacro.Value = "Nightly Build Result (COMPLETED)"
case vbldBuildCompAborted
objMacro.Value = "Nightly Build Result (ABORTED)"
case vbldBuildCompFailed
objMacro.Value = "Nightly Build Result (FAILED)"
case else
objMacro.Value = "Nightly Build Result (UNKNOWN STATUS='" + CStr(status) + "')"
end Select

msgbox "Test 4, objMacro.Value = " & objMacro.Value, vbOK, "CreateXmlLogHandlingProject"

' create a "EmailContent" macro containing the content of the email
Set objMacro = objApp.Project.Macros.Add("EmailContent")

msgbox "Test 5", vbOK, "CreateXmlLogHandlingProject"

Select case status
case vbldBuildCompDone
objMacro.Value = Application.ExpandMacrosAndScript("At %DATETIME%, the build '%PROJFILE%' on %COMPUTERNAME% completed successfully.") + vbCrLf + vbCrLf + vbCrLf
case vbldBuildCompAborted
objMacro.Value = Application.ExpandMacrosAndScript("At %DATETIME%, the build '%PROJFILE%' on %COMPUTERNAME% was canceled by the user.") + vbCrLf + vbCrLf + vbCrLf
case vbldBuildCompFailed
objMacro.Value = Application.ExpandMacrosAndScript("At %DATETIME%, the build '%PROJFILE%' on %COMPUTERNAME% failed.") + vbCrLf + vbCrLf + vbCrLf
case else
objMacro.Value = Application.ExpandMacrosAndScript("At %DATETIME%, the build '%PROJFILE%' on %COMPUTERNAME% exit with unknow status: '") + CStr(status) + "'" + vbCrLf + vbCrLf + vbCrLf
end Select

msgbox "Test 6, objMacro.Value = " & objMacro.Value, vbOK, "CreateXmlLogHandlingProject"

' add a "Group" step and set its properties
With CreateStep(vbldStepMain, "Group", "XML log handling", 0)
.Property("condcomparison") = 6
.Property("condexpr") = "[Len(%QUOTE_STR(%XmlFilePath%)%) > 0 And ""%LogFormat%"" = ""XML""]"
.Property("description") = "Show extra capabilities for XML log files only, processed only if log format is XML"
End With

msgbox "Test 7", vbOK, "CreateXmlLogHandlingProject"

' add a "Transform XML Log" step and set its properties
With CreateStep(vbldStepMain, "Transform XML Log", "Generate HTML log", 1)
.Property("Build0") = -1
.Property("Build1") = -1
.Property("Build2") = -1
.Property("CloseTags") = -1
.Property("InputFile") = "%XmlFilePath%"
.Property("Log0") = -1
.Property("Log1") = -1
.Property("Log2") = -1
.Property("Log3") = -1
.Property("Log4") = -1
.Property("LogNested") = -1
.Property("OutputFile") = "%HtmlFilePath%"
.Property("ShowFile") = -1
.Property("Step0") = -1
.Property("Step1") = -1
.Property("Step2") = -1
.Property("Step3") = -1
.Property("Step4") = -1
.Property("Step5") = -1
.Property("Step6") = -1
.Property("XSLTFile") = "%VISBUILDDIR%\Style\TransformLog.xslt"
.Property("description") = "Perform transform on log file, converting to formatted HTML log with summary, uses built-in XSLT stylesheet"
End With

msgbox "Test 8", vbOK, "CreateXmlLogHandlingProject"

' add a "Send Mail" step and set its properties
With CreateStep(vbldStepMain, "Send Mail", "Send Log File", 1)
.Property("Attachments") = "%HtmlFilePath%"
.Property("Domain") = "%USERDNSDOMAIN%"
.Property("From") = "%USERNAME%@%USERDNSDOMAIN%"
.Property("Message") = "%EmailContent%"
.Property("Port") = 25
.Property("Server") = "%Server%"
.Property("Subject") = "%EmailSubject%"
.Property("Timeout") = 10
.Property("To") = "%TO_EMAIL%"
.Property("description") = "Send the log file via email"
End With


' save the project to disk to build in following step
'objApp.Project.Save "TEMP\dynamic.bld"

'MsgBox "Dynamic file location: TEMP\dynamic.bld", vbOkOnly, "Visual Build Pro"

' build the dynamic project
objBld.SyncBuild



End Function


' add a step to the project and return
Function CreateStep(typ, action, name, indent)
Set objStep = objApp.Project.Steps(typ).Add(action)
objStep.Name = name
objStep.Indent = indent
Set CreateStep = objStep
End Function
Reply With Quote
  #2  
Old 03-04-2010, 11:45 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
It looks like you have extra double quotes here:

Select case status
case vbldBuildCompDone
objMacro.Value = ""%myEmail%"
case vbldBuildCompAborted
objMacro.Value = ""%myEmail%"
case vbldBuildCompFailed
objMacro.Value = "%myEmail%"
case else
objMacro.Value = ""%myEmail%"
end Select

which should be

Select case status
case vbldBuildCompDone
objMacro.Value = "%myEmail%"
case vbldBuildCompAborted
objMacro.Value = "%myEmail%"
case vbldBuildCompFailed
objMacro.Value = "%myEmail%"
case else
objMacro.Value = "%myEmail%"
end Select
Reply With Quote
  #3  
Old 03-05-2010, 01:10 AM
citect citect is online now
Registered User
 
Join Date: 11-13-2008
Posts: 30
The extra quotes are a typo mistake. They do not exist in my real script.
The function now seems to work for failed and done status but it is still not working for the abort status.
Reply With Quote
  #4  
Old 03-05-2010, 10:32 AM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
I'm not sure -- Changing the event code to:

Function vbld_BuildDone(status)
CreateXmlLogHandlingProject(vbldBuildCompDone)
CreateXmlLogHandlingProject(vbldBuildCompFailed)
CreateXmlLogHandlingProject(vbldBuildCompAborted)
End Function

and building succeeds in our tests. Please send the info requested here:
http://www.kinook.com/Forum/showthre...?threadid=3044
Reply With Quote
  #5  
Old 03-07-2010, 05:17 PM
citect citect is online now
Registered User
 
Join Date: 11-13-2008
Posts: 30
1) The info from Help | About | Install Info:

Visual Build Professional 7.2a
Registered to: Citect by Schneider Electric (5-computer license)
Windows Version: 5.1.2600.3.0
Install path: C:\Program Files\VisBuildPro7
HideConsole.exe version 1.0.0.0
SftPrintPreview_IX86_U_20.dll version 2.02
VisBuildCmd.exe version 7.2.1.1
VisBuildPro.exe version 7.2.1.3
VisBuildAct.dll version 7.2.1.3
VisBuildCore.dll version 7.2.1.2
VisBuildDotNET.dll version 7.2.1.0
VisBuildExt.dll version 7.2.1.2
VisBuildMisc.dll version 7.2.1.2
VisBuildMS.dll version 7.2.1.1
VisBuildMS2.dll version 7.2.1.0
VisBuildNet.dll version 7.2.1.2
VisBuildSvr.dll version 7.2.1.3
VisBuildSvr.Interop.dll version 1.0.0.0
VisBuildVCS.dll version 7.2.1.1

2) Configuration Files:
See attached zip file

3) Other program Info:
Not Applicable

4) Problem Description:
See previous post. Also I attached the full bld file. The project is run from VisBuildPro.exe.

5) Detailed steps to reproduce the problem:
a) Failed Status(script works)
Run the bld project then press cancel when asked to enter a value to the macro.
b) Abort Status(script does not work)
Step the first step and then press the abort buton

6) bld file to reproduce the problem:
You will need to change the following line:
.Property("Server") = "AMAUSYD2.au.schneider-electric.com"

7) Log files:
Please not that when the bld project is aborted then there is no log file generated. I attached the log file when the bld project failed. I attached the trace from the output window from both scenarios(Failed status & Abort status).
Attached Files
File Type: zip visual build professional 7.zip (4.3 KB, 2622 views)
Reply With Quote
  #6  
Old 03-08-2010, 10:09 AM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
I don't see a .bld file in the attachment.
Reply With Quote
  #7  
Old 03-08-2010, 04:31 PM
citect citect is online now
Registered User
 
Join Date: 11-13-2008
Posts: 30
Sorry do not know what happened. re-attached with the bld proj
Attached Files
File Type: zip visual build professional 7.zip (11.9 KB, 2530 views)
Reply With Quote
  #8  
Old 03-08-2010, 04:57 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
When I build the project, I get a prompt for CompileDir undefined macro, and after canceling the prompt:


Deleting log file 'C:\Users\user\DriverBuild.xml' from vbld_BuildStarting event (go to Script Editor, Project tab to view script code).

3/8/2010 2:53:08 PM: -------------------- Starting Build: 'DriverBuild.bld' --------------------
3/8/2010 2:53:08 PM: Building project step 1 - Project steps...
3/8/2010 2:53:08 PM: Building project step 2 - usage issue...
3/8/2010 2:53:08 PM: Building project step 3 - Exit...
Error expanding macros or script in property Message: VisBuildCmd.exe DriverListFile="path" InstallerOutputDir="path" [SignCommonName="name" EULA="path"] VisualBuildProjectFile

Required Properties:
DriverListFile - XML file containing the list of drivers to be included
InstallerOutputDir - Folder where the Diver Pack will be copied into
Optional Properties:
SignCommonName - Common name for certificate to use for signing. Default "Schneider Electric"
EULA - End Usr License Agreement to use in the Driver Pack Installer. Default checked in at
<Undefined macro CompileDir>
3/8/2010 2:53:46 PM: Build ended (elapsed = 00:00:38).

status = 1


Test 1


Test 2, objMacro.Value = <email addresses>


Test 3


Test 4, objMacro.Value = Nightly Build Result (FAILED)


Test 5


Test 6, objMacro.Value = At 3/8/2010 2:53:46 PM, the build 'D:\Temp\support\DriverBuild.bld' on XYZ failed.





Test 7


Test 8



I also tried adding an Exit step (status of Cancel) at the beginning of the project, which results in:

3/8/2010 2:55:02 PM: -------------------- Starting Build: 'DriverBuild.bld' --------------------
3/8/2010 2:55:02 PM: Building project step 1 - Project steps...
3/8/2010 2:55:02 PM: Building project step 2 - Exit...
3/8/2010 2:55:02 PM: Build canceled by user (elapsed = 00:00:00).

status = 2


Test 1


Test 2, objMacro.Value = <email address>


Test 3


Test 4, objMacro.Value = Nightly Build Result (ABORTED)


Test 5


Test 6, objMacro.Value = At 3/8/2010 2:55:02 PM, the build 'D:\Temp\support\DriverBuild.bld' on XYZ was canceled by the user.





Test 7


Test 8


A log file is created in both cases.
Reply With Quote
  #9  
Old 03-08-2010, 05:25 PM
citect citect is online now
Registered User
 
Join Date: 11-13-2008
Posts: 30
To abort the script I used the "stop (ctrl+break)" button, the status is still abort but the project does not seem to complete.

If I run the bld project from visualcmd and the user press ctrl+break, will the project run to the end. I would like to receive an email when the user abort the project.
Reply With Quote
  #10  
Old 03-08-2010, 06:08 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
A couple problems with this:
1) The file loggers are currently disposed of before the vbld_BuildDone script event fires.
2) When the build is canceled, if the vbld_BuildDone event takes very long to run, it will be aborted (to handle the situation of a build being aborted while script code is executing, but it should wait for this particular event to finish).

We'll investigate explicitly supporting this in the future (there's also a request to support building failure steps if the build is canceled, which would provide another way to achieve this).

For now, you might try shortening the event script code (maybe just call Builder.RunProgram to invoke a pre-defined send mail project, passing dynamic parameters on the command-line).
Reply With Quote
  #11  
Old 03-08-2010, 06:18 PM
citect citect is online now
Registered User
 
Join Date: 11-13-2008
Posts: 30
thanks for that. How can I be notified when you implemented point 2)?
Reply With Quote
  #12  
Old 03-08-2010, 06:41 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
We'll notify on this thread and also see http://www.kinook.com/Forum/showthre...?threadid=2985
Reply With Quote
  #13  
Old 03-11-2010, 10:21 AM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
These are implemented in v7.5.
http://www.kinook.com/Forum/showthre...?threadid=4415
Reply With Quote
  #14  
Old 03-24-2010, 12:38 AM
citect citect is online now
Registered User
 
Join Date: 11-13-2008
Posts: 30
Hi

I installed the visualbuild 7.5 and one of my step is not working anymore.

1) See attached file
2) See attached file
3) N/A
4) The step "148 - Source-index The Driver PDBs..." in my project is not working anymore when using VisBuilCmd.exe. The step is just a "command" step This step used to work with 7.2a. Also this step is working if I use VisBuildPro.exe, not sure what is the difference!!
Attached the log file for both command "VisBuilCmd.exe" and "VisBuildPro.exe" of 7.5
5) Reproduceable with my project but required special structure.
6) See attached file
7) See attached file
Attached Files
File Type: zip kinook.zip (55.6 KB, 2497 views)
Reply With Quote
  #15  
Old 03-24-2010, 01:26 AM
citect citect is online now
Registered User
 
Join Date: 11-13-2008
Posts: 30
I find a way for you to reproduce it using the attached file. The project works if using VisBuildPro but not with VisProCmd. You will need to change the path of the bat file in step 2.


The output expected should be:

echo "/Source=D:\DrvGrp\NonODC\VC8\Drivers\DNPr\Developme nt\Branch2"
"/Source=D:\DrvGrp\NonODC\VC8\Drivers\DNPr\Developme nt\Branch2"

D:\DrvGrp\NonODC\Utilities\DriverPackBuilder>echo "/Symbols=\\syd-file01\volatile\TDG\Release Symbols\Products\Drivers\DNPR\4.02.24.001"
"/Symbols=\\syd-file01\volatile\TDG\Release Symbols\Products\Drivers\DNPR\4.02.24.001"

D:\DrvGrp\NonODC\Utilities\DriverPackBuilder>echo "/Debug=1"
"/Debug=1"

rem D:\DrvGrp\NonODC\Utilities\DriverPackBuilder\tfsin dex.cmd "/Source=D:\DrvGrp\NonODC\VC8\Drivers\DNPr\Developme nt\Branch2" "/Symbols=\\syd-file01\volatile\TDG\Release Symbols\Products\Drivers\DNPR\4.02.24.001" "/Debug=1"
Attached Files
File Type: zip kinook2.zip (823 Bytes, 2508 views)
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



All times are GMT -5. The time now is 01:51 PM.


Copyright © 1999-2023 Kinook Software, Inc.