Share via


Specifying Build Events

You can use build events to specify commands that run before the build starts, before the link process, or after the build finishes.

Build events are executed only if the build successfully reaches those points in the build process. If an error occurs in the build, the Post-Build event will not occur; if the error occurs before the linking phase, neither the Pre-Link nor the Post-Build event will occur. Additionally, if no files need to be linked, the Pre-Link event will not occur. The Pre-Link event is also not available in projects that do not contain a link step.

If no files need to be built, no build events will occur.

For general information on build events, see Understanding Custom Build Steps and Build Events.

To specify a build event

  1. In Solution Explorer, select the project for which you want to specify the build event.

  2. Open the project's Property Pages dialog box. For details, see Setting Visual C++ Project Properties.

  3. In the Build Events folder, select a build event property page.

  4. Specify the properties associated with the build event:

    • In Command Line, specify the syntax of the build event. This syntax can include any command that is legal at the command line or in a .bat file. You may want to use Macros for Build Commands and Properties to specify locations for files or to get the actual name of the input file in the case of multiple selections. The name of a batch file should be preceded by call to ensure that all subsequent commands will be executed.

    • In Description, type a description for this event. This will be printed to the Output window when this event occurs.

    • In Excluded From Build, specify Yes if you do not want the event to run.

See Also

Reference

Understanding Custom Build Steps and Build Events

Troubleshooting Custom Build Steps and Build Events

Other Resources

Macros for Build Commands and Properties