This documentation is archived and is not being maintained.

Build Events, Common Properties, <Projectname> Property Pages Dialog Box

Visual Studio .NET 2003

The Build Events property page in the Common Properties folder (not available for Web applications) contains the following properties:

Pre-build Event Command Line
Command to execute before the build starts. To type long commands, click the Ellipsis (...) button at the end of the line to display an edit box.
Post-build Event Command Line
Command to execute after the build ends. To type long commands, click the Ellipsis button at the end of the line to display an edit box.
Run the Post-build Event?
Specifies the following conditions for the post-build event to run, as shown in the following table.
Option Result
Always Post-build event will run regardless of whether the build succeeds.
On successful build Post-build event will run if the build succeeds. Thus, the event will run even for a project that is up-to-date, as long as the build succeeds.
When the build updates the project output Post-build event will only run when the compiler's output file (.exe or .dll) is different than the previous compiler output file. Thus, a post-build event is not run if a project is up-to-date.
Note   You can use build events to specify commands that run before the build starts or after the build finishes. Build events are executed only if the build successfully reaches those points in the build process.

When a project is built, pre-build events are placed in a file called PreBuildEvent.bat and post-build events are placed in a file called PostBuildEvent.bat. If you want to ensure error checking, add your own error checking commands to the build steps.

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 and specify the syntax of the build event.

    This syntax can include any command that is valid at the command line or in a .bat file. The name of a batch file should be preceded by call to ensure that all subsequent commands will be executed.

    You may want to use the following macros to specify locations for files or to get the actual name of the input file in the case of multiple selections. These macros are not case-sensitive.

    Macro Description
    $(ConfigurationName) The name of the current project configuration, for example, "Debug".
    $(PlatformName) The name of current project platform, for example, "Win32".
    $(OutDir) Path to the output file directory, relative to the project directory. This resolves to the value for the Output Directory property. It includes the trailing backslash '\'.
    $(DevEnvDir) The installation directory of Visual Studio .NET (defined as drive + path); includes the trailing backslash '\'.
    $(ProjectDir) The directory of the project (defined as drive + path); includes the trailing backslash '\'.
    $(ProjectPath) The absolute path name of the project (defined as drive + path + base name + file extension).
    $(ProjectName) The base name of the project.
    $(ProjectFileName) The file name of the project (defined as base name + file extension).
    $(ProjectExt) The file extension of the project. It includes the '.' before the file extension.
    $(SolutionDir) The directory of the solution (defined as drive + path); includes the trailing backslash '\'.
    $(SolutionPath) The absolute path name of the solution (defined as drive + path + base name + file extension).
    $(SolutionName) The base name of the solution.
    $(SolutionFileName) The file name of the solution (defined as base name + file extension).
    $(SolutionExt) The file extension of the solution. It includes the '.' before the file extension.
    $(TargetDir) The directory of the primary output file for the build (defined as drive + path). It includes the trailing backslash '\'.
    $(TargetPath) The absolute path name of the primary output file for the build (defined as drive + path + base name + file extension).
    $(TargetName) The base name of the primary output file for the build.
    $(TargetFileName) The file name of the primary output file for the build (defined as base name + file extension).
    $(TargetExt) The file extension of the primary output file for the build. It includes the '.' before the file extension.

    See PreBuildEvent, PostBuildEvent, and RunPostBuildEvent for information on how to programmatically access this property.

Smart Device Developer Notes

Build Events, Common Properties
Not supported.

See Also

Setting Visual C# Project Properties

Show: