AutoBld: Builds One or More Workspaces at Specified Times and Dates

Click to open or copy the AutoBld project files.

This sample builds a Visual C++ project at a specified time. When the build is done, AutoBld emails the user with the name of the configuration and the number of build warnings and errors. The code demonstrates working with various parts of the Developer Studio object model, placing multiple commands into an add-in, and invoking commands from a command line.

For the Send Email function to work, you either need a non-password email account, or you need to be logged into the email account at the time AutoBld runs.

To build the sample

  1. Click the link at the beginning of this topic to download the sample files.

  2. In Visual C++, open the project file AutoBld.dsp.

  3. Choose an appropriate configuration (Win32 Release is best if you plan to use this add-in).

  4. Click Rebuild All from the Build menu.

  5. Place AutoBld.dll in \Microsoft Visual Studio\Common\MSDev98\AddIns so it can be located by Visual C++ when it launches.

To run the sample on Windows NT

  1. From the Tools menu, click Customize.

  2. Click the Add-ins and Macro Files tab.

  3. Select the AutoBld.dll file or browse for it. See Tips for Using Add-ins.

  4. Once the AutoBld add-in has been loaded, clicking the button on the add-in toolbar opens a dialog box that lets you specify where build time information is to be logged. The file is persistent; any changes to it will be used next time.

  5. Click the Configure button on the newly created toolbar, and set your preferences in the AutoBuild Configuration dialog box.

  6. Exit Visual C++ to save this configuration.

  7. From Control Panel, open the Services dialog box. Find Scheduling Agent in the list box, and make sure its Status column indicates Started and its Startup column indicates Automatic. If the Scheduling Agent's Status is not set to Started, highlight the Scheduling Agent and click the Start button. If its Startup is not set to Automatic, click the Startup button and select Automatic in the Startup Type field on the Service dialog box.

  8. From a command prompt, use the at utility to set the time and date to build your workspaces. When giving the at utility a command line to execute, enter the following line (making sure that msdev.exe is on your path):

Example

at 06:00 /interactive msdev.exe /EX AutoBuildTest

This will launch Visual C++ and execute the AutoBuild command at 06:00 am, which starts the build of your workspaces.

To run the sample on Windows 95 with Microsoft PLUS!

  1. Follow the procedure earlier in this topic on running the sample through Step 6 (where you exit Visual C++ to save the configuration).

  2. Click the Scheduling Agent on the system tray, and add the following line to the list of tasks to perform:
    msdev /EX AutoBuildTest
    

    Note   The Scheduling Agent icon appears next to the clock in the system tray in the lower-right corner of your screen (on the Start taskbar). This is only visible if Microsoft PLUS! is installed.

  3. Set the time and how often you want to execute the build.

This sample demonstrates the following keywords:

CString::LoadString; CComModule::Init; CWinApp::InitInstance; CComModule::Term; CComModule::GetClassObject; CComModule::GetLockCount; CComModule::RegisterServer; CRegKey::Open; CoTaskMemFree; CComModule::UnregisterServer; GetProfileString; GetProfileInt; AddRef; AfxGetStaticModuleState; LoadLibrary; GetProcAddress; CString::Format; FreeLibrary; CCommandsObj::CreateInstance; GetLastErrorDescription; GetNextItem