Microsoft Corporation
April 1, 1997
An automated build is a project build in Visual Studio™ that can be scheduled to start at a specific time, like late at night, and finish by itself. In the add-in sample provided for automated builds, the build log can be emailed to the person of your choice. You can use an automated build for the debug, release or both configurations of your project, or you can build multiple projects.
There are four ways to automate the build process:
This article focuses on the first two options, building with the add-in or with a VBScript macro, examples of which are provided here. The other two options, exporting a makefile and opening MSDev as an object, are beyond the scope of this paper.
An add-in is an in-process ActiveX™ component (DLL) written in any programming language (that supports ActiveX), such as Visual C++® or Visual Basic®, whereas a VBScript macro is written in the Visual Basic Scripting Edition (VBScript) language. An add-in must be coded in that language, compiled into a DLL, and then installed in Visual Studio, but a VBScript macro can be created by recording the macro as well as by typing the macro in an editor.
An add-in can access all the local computer resources as well as the object model. The VBScript macros are limited to the Developer Studio™ object model. An add-in can control another application (.EXE) easily, but a VBScript macro can only control another application that is signed and safe, like the typical Web control. An add-in can use the Windows® API to directly read from or write to files on disk (a VBScript macro can access files but not through the API).
For more on the differences between an add-in and a VBScript macro, see the topic "Differences Between VBScript Macros and Developer Studio Add-ins" (MSDN Library, Visual C++ Documentation, Developer Studio Environment User’s Guide, Automating Tasks in Developer Studio, VBScript Macros).
Visual Studio includes samples of add-ins to use or modify, including a sample that automates a build process, AutoBuild. This builds a Visual C++ or Visual J++™ project at a specified time. When the build is done, AutoBuild emails the specified user with the name of the configuration and the number of warnings or errors. You can find and copy AutoBuild to your local drive by searching the online documentation for "AutoBld," or by looking up the topic "Copying the Sample Add-ins" (MSDN Library, Visual C++ Documentation, Developer Studio Environment User’s Guide, Automating Tasks in Developer Studio, Developer Studio Add-ins).
Optionally, you can generate a build log file (*.PLG file). Any time a build occurs, the .PLG file is overwritten with the latest information. For multiple builds, save or move the .PLG file before starting the next release or debug build. The .PLG file is stored in the project directory that you build.
To set up the AutoBuild add-in, follow these steps:
or
Run AutoBuild in Windows NT 4.0.
To copy the AutoBuild add-in to your local computer:
To build and enable the AutoBuild add-in:
To run AutoBuild in Visual Studio using Windows® 95 (Microsoft Plus! required):
msdev -execute AutoBuild
To run AutoBuild in Visual Studio using Windows NT® 4.0:
msdev –execute AutoBuild
This will launch the Developer Studio environment and execute the AutoBuild command, which starts the build of your projects.
To get help on the “at” utility, type "at ?" at the command line.
Note You must disable the Tip of the Day dialog box in Visual Studio before activating any add-ins, such as AutoBuild, from the command line.
For more information on add-ins in Visual Studio, look up the topic "Overview: Developer Studio Add-ins" (MSDN Library, Visual C++ Documentation, Developer Studio Environment User’s Guide, Automating Tasks in Developer Studio, Developer Studio Add-ins).
A VBScript macro provides another method of doing a scheduled build. There are two ways to create a VBScript macro: record one in the Visual Studio environment, or type one in as a macro file (a .DSM file). VBScript macro files can contain more than one macro. The sample VBScript macro included here, DoAllFire, builds everything in the workspace. The macro script includes code that will build just the release or debug configurations. You can easily modify the DoAllFire macro to contain your own projects and workspaces and build everything or just the configurations and files you wish.
To install the DoAllFire macro file, Buildsam.dsm:
Warning If you remove the check mark next to a macro file name, you unload it. When you unload it, all of the macros in the file lose their toolbar and keystroke assignments.
To edit a VBScript macro:
Running the VBScript Macro, DoAllFire:
After installing the VBScript macro, you can run the macro DoAllFire in the file Buildsam.dsm. You can run macros from toolbar buttons or key sequences assigned to the macros, from the Macros dialog box, or from the command line. For more information on the first two methods, see the topic "Running VBScript Macros" (MSDN Library, Visual C++ Documentation, Developer Studio Environment User’s Guide, Automating Tasks in Developer Studio, Developer Studio VBScript Macros).
To run a macro from the command line:
msdev -ex DoAllFire
DoAllFire is the name of the macro. This syntax starts the Developer Studio environment, and after the main window appears, the macro starts running.
If you want Visual Studio to shut down after the build is complete, edit the macro so that it calls the Application’s object Quit method.
To automate a macro on a schedule (with Windows 95):
msdev -ex DoAllFire
To automate a macro on a schedule (with Windows NT):
msdev -ex DoAllFire
This will launch the Developer Studio environment and execute the AutoBuild command, which starts the build of your projects.
To get help on the “at” utility, type "at ?" at the command line. For example, to run the macro "DoAllFire" at 1:00 AM, use the command:
AT 1:00am "msdev -ex DoAllFire"
To debug a VBScript macro:
For more information on add-ins in Visual Studio, look up the topic "Overview: Developer Studio VBScript Macros" (MSDN Library, Visual C++ Documentation, Developer Studio Environment User’s Guide, Automating Tasks in Developer Studio, Developer Studio VBScript Macros).