Navigation:  Samples >

Script.bld Sample

Previous pageReturn to chapter overviewNext page

This sample demonstrates how to integrate and call custom scripts for complex build capabilities. 

 

1.Dictionary: Demonstrates initializing a collection of values using the Dictionary object, storing in a temporary macro, and using in a later step.
2.Numeric comparison: Using a VBScript expression to perform a numeric comparison and conditionally build the step.
3.Increment macro: How to call a script to increment a build number macro and then use the macro in the following step.
4.Process files: The next set of steps uses the Process Files action and a Run Script step to perform an incremental copy of the sample files to another directory.  The first time the project is built, all the files are copied, but if built again, it detects that all files are up-to-date and does not copy them.  Note: The Copy Files action could also be used to do this, but this technique could be useful if other processing needed to be performed if a file was out of date.
5.Miscellaneous: How to create a shortcut from script, check for an application running, using OLE Automation to modify an Excel spreadsheet (from http://support.microsoft.com/default.aspx?kbid=260410), and pausing from script code (samples for 3 different script languages provided).
6.Object model: Using the Visual Build Pro object model to:
Log all steps and properties in a project
Dynamically create a new project and build it.  This could be useful if a build is driven by the contents of an external configuration file that determines what to build.  Steps and macros can be added to the project, their properties set, and the project built to build all steps.  First, create a template step manually inside of Visual Build Pro, then open the .bld file in a text editor and view that step's child elements to see what properties need to be set (or copy and paste the 'Log all steps and properties' step from this sample into your project and build to see all steps and properties).  The action attribute is passed into the step Add method.
Show and manipulate the build objects during a build, and then logging the changes that were made.  This can be useful to configure Visual Build Pro on a clean build box with the values pulled from config and macro files stored in source control, for instance.

 

Note: Some things to be aware of when working with Excel samples:

 

1) Remove ' As <Excel.Application>' from variable declarations (everything is a variant in VBScript).

2) VBScript doesn't support named parameters (i.e. xlApp.Workbooks.Open FileName:="c:\My Documents\Book1.xls); pass all required parameters in the order required without naming.

3) Use the actual numeric value of constants defined in the Excel object model, since these constants aren't available from script.

 

See the Microsoft Excel Visual Basic Reference in the Excel help for details on 2 and 3.

 

 

The Logging.bld sample demonstrates some additional scripting techniques.